Skip to content

Commit

Permalink
fix(cli): add noindex for changelog (#6021)
Browse files Browse the repository at this point in the history
* add for changelog

* pipe through

* update tests

* update schema

---------

Co-authored-by: fern-bot <info@buildwithfern.com>
  • Loading branch information
chdeskur and fern-support authored Feb 17, 2025
1 parent 1b688a6 commit 973586b
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/cli/docs-resolver/src/ApiReferenceNodeConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class ApiReferenceNodeConverter {
private docsWorkspace: DocsWorkspace,
private taskContext: TaskContext,
private markdownFilesToFullSlugs: Map<AbsoluteFilePath, string>,
private markdownFilesToNoIndex: Map<AbsoluteFilePath, boolean>,
idgen: NodeIdGenerator
) {
this.disableEndpointPairs = docsWorkspace.config.experimental?.disableStreamToggle ?? false;
Expand Down Expand Up @@ -88,6 +89,7 @@ export class ApiReferenceNodeConverter {
const pointsTo = FernNavigation.V1.followRedirects(this.#children);
const changelogNodeConverter = new ChangelogNodeConverter(
this.markdownFilesToFullSlugs,
this.markdownFilesToNoIndex,
this.workspace.changelog?.files.map((file) => file.absoluteFilepath),
this.docsWorkspace,
this.#idgen
Expand Down Expand Up @@ -160,6 +162,7 @@ export class ApiReferenceNodeConverter {
parentSlug,
docsWorkspace: this.docsWorkspace,
markdownFilesToFullSlugs: this.markdownFilesToFullSlugs,
markdownFilesToNoIndex: this.markdownFilesToNoIndex,
idgen: this.#idgen
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class ApiReferenceNodeConverterLatest {
private docsWorkspace: DocsWorkspace,
private taskContext: TaskContext,
private markdownFilesToFullSlugs: Map<AbsoluteFilePath, string>,
private markdownFilesToNoIndex: Map<AbsoluteFilePath, boolean>,
idgen: NodeIdGenerator
) {
this.#api = api;
Expand Down Expand Up @@ -92,6 +93,7 @@ export class ApiReferenceNodeConverterLatest {
const pointsTo = FernNavigation.V1.followRedirects(this.#children);
const changelogNodeConverter = new ChangelogNodeConverter(
this.markdownFilesToFullSlugs,
this.markdownFilesToNoIndex,
this.workspace?.changelog?.files.map((file) => file.absoluteFilepath),
this.docsWorkspace,
this.#idgen
Expand Down Expand Up @@ -161,7 +163,8 @@ export class ApiReferenceNodeConverterLatest {
page,
parentSlug,
idgen: this.#idgen,
markdownFilesToFullSlugs: this.markdownFilesToFullSlugs
markdownFilesToFullSlugs: this.markdownFilesToFullSlugs,
markdownFilesToNoIndex: this.markdownFilesToNoIndex
});
}

Expand Down
7 changes: 5 additions & 2 deletions packages/cli/docs-resolver/src/ChangelogNodeConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const RESERVED_OVERVIEW_PAGE_NAMES = ["summary", "index", "overview"];
export class ChangelogNodeConverter {
public constructor(
private markdownToFullSlug: Map<AbsoluteFilePath, string>,
private markdownToNoIndex: Map<AbsoluteFilePath, boolean>,
private changelogFiles: AbsoluteFilePath[] | undefined,
private docsWorkspace: DocsWorkspace,
private idgen: NodeIdGenerator
Expand Down Expand Up @@ -73,6 +74,8 @@ export class ChangelogNodeConverter {
urlSlug: opts.slug ?? kebabCase(title)
});

const noindex = overviewPagePath != null ? this.markdownToNoIndex.get(overviewPagePath) : undefined;

// sort changelog items by date, in descending order
const changelogItems = unsortedChangelogItems.map((item): FernNavigation.V1.ChangelogEntryNode => {
const date = dayjs.utc(item.date);
Expand All @@ -91,7 +94,7 @@ export class ChangelogNodeConverter {
hidden: undefined,
date: item.date.toISOString(),
pageId: item.pageId,
noindex: undefined,
noindex: this.markdownToNoIndex.get(item.absoluteFilepath),
authed: undefined,
viewers: undefined,
orphaned: undefined,
Expand All @@ -114,7 +117,7 @@ export class ChangelogNodeConverter {
hidden: opts.hidden,
children: changelogYears,
overviewPageId,
noindex: undefined,
noindex,
authed: undefined,
viewers: opts.viewers,
orphaned: opts.orphaned,
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/docs-resolver/src/DocsDefinitionResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ export class DocsDefinitionResolver {
this.docsWorkspace,
this.taskContext,
this.markdownFilesToFullSlugs,
this.markdownFilesToNoIndex,
this.#idgen
);
return node.get();
Expand All @@ -715,6 +716,7 @@ export class DocsDefinitionResolver {
this.docsWorkspace,
this.taskContext,
this.markdownFilesToFullSlugs,
this.markdownFilesToNoIndex,
this.#idgen
);
return node.get();
Expand Down Expand Up @@ -751,6 +753,7 @@ export class DocsDefinitionResolver {
this.docsWorkspace,
this.taskContext,
this.markdownFilesToFullSlugs,
this.markdownFilesToNoIndex,
this.#idgen
);
return node.get();
Expand All @@ -762,6 +765,7 @@ export class DocsDefinitionResolver {
): Promise<FernNavigation.V1.ChangelogNode> {
const changelogResolver = new ChangelogNodeConverter(
this.markdownFilesToFullSlugs,
this.markdownFilesToNoIndex,
item.changelog,
this.docsWorkspace,
this.#idgen
Expand Down Expand Up @@ -879,6 +883,7 @@ export class DocsDefinitionResolver {
): Promise<FernNavigation.V1.ChangelogNode> {
const changelogResolver = new ChangelogNodeConverter(
this.markdownFilesToFullSlugs,
this.markdownFilesToNoIndex,
changelog,
this.docsWorkspace,
this.#idgen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ it.skip("converts to api reference node", async () => {
docsWorkspace,
context,
new Map(),
new Map(),
NodeIdGenerator.init()
).get();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ it.skip("converts to api reference latest node", async () => {
docsWorkspace,
context,
new Map(),
new Map(),
NodeIdGenerator.init()
).get();

Expand Down
1 change: 1 addition & 0 deletions packages/cli/docs-resolver/src/__test__/stream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ it.skip("converts to api reference node", async () => {
docsWorkspace,
context,
new Map(),
new Map(),
NodeIdGenerator.init()
).get();

Expand Down
6 changes: 4 additions & 2 deletions packages/cli/docs-resolver/src/utils/toPageNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ export function toPageNode({
page,
parentSlug,
idgen,
markdownFilesToFullSlugs
markdownFilesToFullSlugs,
markdownFilesToNoIndex
}: {
docsWorkspace: DocsWorkspace;
page: docsYml.DocsNavigationItem.Page;
parentSlug: FernNavigation.V1.SlugGenerator;
idgen: NodeIdGenerator;
markdownFilesToFullSlugs: Map<AbsoluteFilePath, string>;
markdownFilesToNoIndex: Map<AbsoluteFilePath, boolean>;
}): FernNavigation.V1.PageNode {
const pageId = FernNavigation.V1.PageId(toRelativeFilepath(docsWorkspace, page.absolutePath));
const pageSlug = parentSlug.apply({
Expand All @@ -34,7 +36,7 @@ export function toPageNode({
slug: pageSlug.get(),
icon: page.icon,
hidden: page.hidden,
noindex: page.noindex,
noindex: page.noindex || markdownFilesToNoIndex.get(page.absolutePath),
authed: undefined,
viewers: page.viewers,
orphaned: page.orphaned,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,16 @@
"type": "null"
}
]
},
"noindex": {
"oneOf": [
{
"type": "boolean"
},
{
"type": "null"
}
]
}
},
"required": [
Expand Down

0 comments on commit 973586b

Please sign in to comment.