Skip to content

Commit

Permalink
feat: skipUrlSlug in tabs (#943)
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity authored May 31, 2024
1 parent b7476d6 commit 3c97f67
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions fern/apis/fdr/definition/docs/v1/db/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ types:
icon: optional<string>
items: list<NavigationItem>
urlSlug: string
skipUrlSlug: optional<boolean>

UnversionedUntabbedNavigationConfig:
properties:
Expand Down
1 change: 1 addition & 0 deletions fern/apis/fdr/definition/docs/v1/read/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ types:
properties:
title: string
items: list<NavigationItem>
skipUrlSlug: boolean

NavigationTabLink:
properties:
Expand Down
1 change: 1 addition & 0 deletions fern/apis/fdr/definition/docs/v1/write/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ types:
properties:
title: string
items: list<NavigationItem>
skipUrlSlug: optional<boolean>

NavigationTabLink:
properties:
Expand Down
7 changes: 6 additions & 1 deletion packages/commons/fdr-utils/src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,12 @@ function resolveSidebarNodesVersionItems(
if (isUnversionedTabbedNavigationConfig(nav)) {
return nav.tabs.map((tab, index): SidebarNodeRaw.Tab => {
if (tab.type === "group" || (tab.type == null && tab.items != null)) {
const parentSlugs = [...fixedSlugs, ...tab.urlSlug.split("/")];
const parentSlugs =
tab.fullSlug != null
? [...fixedSlugs, ...tab.fullSlug]
: tab.skipUrlSlug
? fixedSlugs
: [...fixedSlugs, ...tab.urlSlug.split("/")];
return {
type: "tabGroup",
title: tab.title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export interface NavigationTabGroup {
icon?: string;
items: FernRegistry.docs.v1.db.NavigationItem[];
urlSlug: string;
skipUrlSlug?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ import * as FernRegistry from "../../../../../../..";
export interface NavigationTabGroup extends FernRegistry.docs.v1.read.NavigationNodeMetadata {
title: string;
items: FernRegistry.docs.v1.read.NavigationItem[];
skipUrlSlug: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ import * as FernRegistry from "../../../../../../..";
export interface NavigationTabGroup extends FernRegistry.docs.v1.write.NavigationNodeMetadata {
title: string;
items: FernRegistry.docs.v1.write.NavigationItem[];
skipUrlSlug?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export function transformNavigationTabForDb(dbShape: DocsV1Db.NavigationTab): Do
type: "group",
...group,
items: group.items.map(transformNavigationItemForDb),
skipUrlSlug: group.skipUrlSlug ?? false,
}),
});
}
Expand All @@ -155,6 +156,7 @@ export function transformNavigationTabV2ForDb(dbShape: DocsV1Db.NavigationTabV2)
return {
...dbShape,
items: dbShape.items.map(transformNavigationItemForDb),
skipUrlSlug: dbShape.skipUrlSlug ?? false,
};
case "changelog":
return dbShape;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export interface NavigationTabGroup {
icon?: string;
items: FernRegistry.docs.v1.db.NavigationItem[];
urlSlug: string;
skipUrlSlug?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import * as FernRegistry from "../../../../../../..";
export interface NavigationTabGroup extends FernRegistry.docs.v1.read.NavigationNodeMetadata {
title: string;
items: FernRegistry.docs.v1.read.NavigationItem[];
skipUrlSlug: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import * as FernRegistry from "../../../../../../..";
export interface NavigationTabGroup extends FernRegistry.docs.v1.write.NavigationNodeMetadata {
title: string;
items: FernRegistry.docs.v1.write.NavigationItem[];
skipUrlSlug?: boolean;
}

0 comments on commit 3c97f67

Please sign in to comment.