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
8 changes: 2 additions & 6 deletions docs/reference/_category_.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"label": "Reference",
"position": 4,
"link": {
"type": "generated-index",
"title": "Reference Documentation",
"description": "Reference documentation and technical specifications",
"keywords": ["reference", "specifications"]
"type": "doc",
"id": "reference/index"
}
}
53 changes: 52 additions & 1 deletion docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,65 @@ const config: Config = {
includeCurrentVersion: false,
versions: {
'4.6': {
banner: 'none', // No banner for this version
// No banner for 4.6 as its the latest version
banner: 'none',
},
'4.5': {
// No banner for 4.5 as its still actively maintained
banner: 'none',
},
},
// Converts npm commands in markdown code blocks to show npm/yarn/pnpm tabs
remarkPlugins: [[require('@docusaurus/remark-plugin-npm2yarn'), { sync: true }]],
// Filter out index files that are used as category links
async sidebarItemsGenerator({ defaultSidebarItemsGenerator, ...args }) {
const sidebarItems = await defaultSidebarItemsGenerator(args);

// Function to recursively process sidebar items
function filterIndexFiles(items: any[]): any[] {
return items
.filter((item) => {
// Filter out index.md files at the root of autogenerated directories
// when they would be duplicates of category links
if (item.type === 'doc' && item.id?.endsWith('/index')) {
// Check if the category metadata has a link to this index
const dirName = args.item?.dirName;
if (dirName && item.id === `${dirName}/index`) {
const categoryMeta = args.categoriesMetadata?.[dirName];
Copy link
Member Author

@heskew heskew Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

args.categoriesMetadata.reference is generated from reference/_category_.json

if (categoryMeta?.link?.type === 'doc' && categoryMeta.link.id === item.id) {
const versionName = args.version?.versionName || 'current';
console.log(`✂️ 🔗 [v${versionName}] Removing ${item.id} from ${dirName} (category link exists)`);
return false;
}
}
// Keep other index files that are in subcategories
return true;
}

// Process categories recursively
if (item.type === 'category' && item.items) {
return {
...item,
items: filterIndexFiles(item.items),
};
}

return true;
})
.map((item) => {
// For categories, recursively filter their items
if (item.type === 'category' && item.items) {
return {
...item,
items: filterIndexFiles(item.items),
};
}
return item;
});
}

return filterIndexFiles(sidebarItems);
},
},
],

Expand Down
4 changes: 4 additions & 0 deletions sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ const sidebars: SidebarsConfig = {
{
type: 'category',
label: 'Reference',
link: {
type: 'doc',
id: 'reference/index',
},
items: [{ type: 'autogenerated', dirName: 'reference' }],
},
],
Expand Down
8 changes: 2 additions & 6 deletions versioned_docs/version-4.5/reference/_category_.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"label": "Reference",
"position": 4,
"link": {
"type": "generated-index",
"title": "Reference Documentation",
"description": "Reference documentation and technical specifications",
"keywords": ["reference", "specifications"]
"type": "doc",
"id": "reference/index"
}
}
8 changes: 2 additions & 6 deletions versioned_docs/version-4.6/reference/_category_.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"label": "Reference",
"position": 4,
"link": {
"type": "generated-index",
"title": "Reference Documentation",
"description": "Reference documentation and technical specifications",
"keywords": ["reference", "specifications"]
"type": "doc",
"id": "reference/index"
}
}
4 changes: 4 additions & 0 deletions versioned_sidebars/version-4.5-sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
{
"type": "category",
"label": "Reference",
"link": {
"type": "doc",
"id": "reference/index"
},
"items": [
{
"type": "autogenerated",
Expand Down
4 changes: 4 additions & 0 deletions versioned_sidebars/version-4.6-sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
{
"type": "category",
"label": "Reference",
"link": {
"type": "doc",
"id": "reference/index"
},
"items": [
{
"type": "autogenerated",
Expand Down