@@ -83,14 +83,65 @@ const config: Config = {
8383 includeCurrentVersion : false ,
8484 versions : {
8585 '4.6' : {
86- banner : 'none' , // No banner for this version
86+ // No banner for 4.6 as its the latest version
87+ banner : 'none' ,
8788 } ,
8889 '4.5' : {
8990 // No banner for 4.5 as its still actively maintained
9091 banner : 'none' ,
9192 } ,
9293 } ,
94+ // Converts npm commands in markdown code blocks to show npm/yarn/pnpm tabs
9395 remarkPlugins : [ [ require ( '@docusaurus/remark-plugin-npm2yarn' ) , { sync : true } ] ] ,
96+ // Filter out index files that are used as category links
97+ async sidebarItemsGenerator ( { defaultSidebarItemsGenerator, ...args } ) {
98+ const sidebarItems = await defaultSidebarItemsGenerator ( args ) ;
99+
100+ // Function to recursively process sidebar items
101+ function filterIndexFiles ( items : any [ ] ) : any [ ] {
102+ return items
103+ . filter ( ( item ) => {
104+ // Filter out index.md files at the root of autogenerated directories
105+ // when they would be duplicates of category links
106+ if ( item . type === 'doc' && item . id ?. endsWith ( '/index' ) ) {
107+ // Check if the category metadata has a link to this index
108+ const dirName = args . item ?. dirName ;
109+ if ( dirName && item . id === `${ dirName } /index` ) {
110+ const categoryMeta = args . categoriesMetadata ?. [ dirName ] ;
111+ if ( categoryMeta ?. link ?. type === 'doc' && categoryMeta . link . id === item . id ) {
112+ const versionName = args . version ?. versionName || 'current' ;
113+ console . log ( `✂️ 🔗 [v${ versionName } ] Removing ${ item . id } from ${ dirName } (category link exists)` ) ;
114+ return false ;
115+ }
116+ }
117+ // Keep other index files that are in subcategories
118+ return true ;
119+ }
120+
121+ // Process categories recursively
122+ if ( item . type === 'category' && item . items ) {
123+ return {
124+ ...item ,
125+ items : filterIndexFiles ( item . items ) ,
126+ } ;
127+ }
128+
129+ return true ;
130+ } )
131+ . map ( ( item ) => {
132+ // For categories, recursively filter their items
133+ if ( item . type === 'category' && item . items ) {
134+ return {
135+ ...item ,
136+ items : filterIndexFiles ( item . items ) ,
137+ } ;
138+ }
139+ return item ;
140+ } ) ;
141+ }
142+
143+ return filterIndexFiles ( sidebarItems ) ;
144+ } ,
94145 } ,
95146 ] ,
96147
0 commit comments