Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion bin/gen-sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function noteOrder(groupPath: string, pages: string[]) {

// ---------------------------------------------------------------- conversion
type NimbusItem =
| { label: string; link: string; badge?: NavBadge; icon?: string; hidden?: boolean }
| { label: string; link: string; badge?: NavBadge; statusBadge?: string; deprecated?: boolean; icon?: string; hidden?: boolean }
| { label: string; items: NimbusItem[]; collapsed?: boolean; segment?: string; landing?: string; icon?: string };

function convertPages(pages: Json[], groupPath: string): NimbusItem[] {
Expand Down Expand Up @@ -399,6 +399,28 @@ const items: NimbusItem[] = tabs.map((t) => {
return { label, items: [], collapsed: false };
});

// Enrich every API link, whether authored as a page, operation pointer, or tag group.
// Keys use pageLink so localized navigation receives the same operation metadata.
if (!previewRemote) {
const apiPages = new Map(
[...getApiOperations("cloud"), ...getApiOperations("clickstack")]
.map((operation) => [pageLink(operation.route), operation]),
);
const enrichApiLinks = (nodes: NimbusItem[]) => {
for (const item of nodes) {
if ("items" in item) {
enrichApiLinks(item.items);
continue;
}
const operation = apiPages.get(item.link);
if (!operation) continue;
item.statusBadge = operation.badge;
item.deprecated = operation.operation.deprecated || undefined;
}
};
enrichApiLinks(items);
}

const outFile = path.join(outDir, locale ? `sidebar.items.${locale}.json` : "sidebar.items.json");
fs.writeFileSync(outFile, JSON.stringify(items, null, 2) + "\n");

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"react-dom": "^19.0.0",
"redirects-in-workers": "^0.0.7",
"satteri": "^0.10.5",
"tailwind-merge": "^3.5.0"
"tailwind-merge": "^3.5.0",
"shiki": "^4.4.3"
},
"devDependencies": {
"@astrojs/check": "^0.9.8",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading