@@ -72,47 +72,43 @@ export default defineConfig({
72
72
text : 'Документация' ,
73
73
items : [
74
74
{ text : 'autumn' , link : '/getting-started/about-autumn' } ,
75
- { text : 'winow' , link : '/winow/' } ,
76
- { text : 'annotations' , link : '/annotations/' } ,
77
- { text : 'autumn-collections' , link : '/autumn-collections/' } ,
75
+ ...getNavBarItems ( 'products/' , false , 'autumn' ) ,
78
76
]
79
77
} ,
80
78
{
81
79
text : 'API' ,
82
80
items : [
83
- { text : 'autumn' , link : '/api/autumn/' } ,
84
- { text : 'annotations' , link : '/api/annotations/' } ,
85
- { text : 'autumn-collections' , link : '/api/autumn-collections/' } ,
81
+ ...getNavBarItems ( 'api/' ) ,
86
82
]
87
83
} ,
88
84
] ,
89
85
90
86
sidebar : {
91
87
// products
92
88
"/" : getSidebar ( {
93
- contentRoot : contentRoot + 'products/autumn/' ,
89
+ contentRoot : contentRoot + 'products/000- autumn/' ,
94
90
contentDirs : [
95
91
{ text : 'Начало работы' , dir : 'getting-started' } ,
96
92
{ text : 'Использование фреймворка' , dir : 'framework-elements' } ,
97
93
] ,
98
94
collapsed : false ,
99
95
} ) ,
100
96
"/annotations/" : getSidebar ( {
101
- contentRoot : contentRoot + 'products/annotations/' ,
97
+ contentRoot : contentRoot + 'products/010- annotations/' ,
102
98
contentDirs : [
103
99
{ text : 'annotations' , dir : '.' }
104
100
] ,
105
101
collapsed : false ,
106
102
} ) ,
107
103
"/autumn-collections/" : getSidebar ( {
108
- contentRoot : contentRoot + 'products/autumn-collections/' ,
104
+ contentRoot : contentRoot + 'products/020- autumn-collections/' ,
109
105
contentDirs : [
110
106
{ text : 'autumn-collections' , dir : '.' }
111
107
] ,
112
108
collapsed : false ,
113
109
} ) ,
114
110
"/winow/" : getSidebar ( {
115
- contentRoot : contentRoot + 'products/winow/' ,
111
+ contentRoot : contentRoot + 'products/010- winow/' ,
116
112
contentDirs : [
117
113
{ text : 'winow' , dir : '.' }
118
114
] ,
@@ -122,14 +118,14 @@ export default defineConfig({
122
118
"/api/autumn/" : getSidebar ( {
123
119
contentRoot,
124
120
contentDirs : [
125
- { text : 'autumn' , dir : 'api/autumn' }
121
+ { text : 'autumn' , dir : 'api/000- autumn' }
126
122
] ,
127
123
collapsed : false ,
128
124
} ) ,
129
125
"/api/annotations/" : getSidebar ( {
130
126
contentRoot,
131
127
contentDirs : [
132
- { text : 'annotations' , dir : 'api/annotations' }
128
+ { text : 'annotations' , dir : 'api/010- annotations' }
133
129
] ,
134
130
collapsed : false ,
135
131
} ) ,
@@ -284,11 +280,34 @@ function getSidebarItem(contentRoot, file: string): DefaultTheme.SidebarItem {
284
280
return sidebarItem ;
285
281
}
286
282
287
- function getPageName ( fileName : string ) {
288
- return fileName
289
- . replace ( / ^ \d + - / , '' )
283
+ function getPageName ( fileName : string , doWordsSplit : boolean = true ) : string {
284
+ const replacedFileName = fileName . replace ( / ^ \d + - / , '' ) ;
285
+ if ( ! doWordsSplit ) return replacedFileName ;
286
+
287
+ return replacedFileName
290
288
. split ( '-' )
291
289
. map ( word => word . charAt ( 0 ) . toUpperCase ( ) + word . slice ( 1 ) )
292
290
. join ( ' ' ) ;
293
291
}
294
292
293
+ function getNavBarItems ( contentDir : string , appendNavBarWithContentDir : boolean = true , exclude : string = '' ) : DefaultTheme . NavItemWithLink [ ] {
294
+
295
+ const navBarItems : DefaultTheme . NavItemWithLink [ ] = [ ] ;
296
+ const cwd = `${ process . cwd ( ) } /${ contentRoot } ` ;
297
+
298
+ const dirs = glob . sync ( `${ contentDir } /*/` , { cwd } ) . sort ( ) ;
299
+
300
+ for ( const dirIndex in dirs ) {
301
+ const dir = dirs [ dirIndex ] ;
302
+
303
+ const text = getPageName ( path . basename ( dir ) , false ) ;
304
+ const link = appendNavBarWithContentDir ? `/${ contentDir } /${ text } /` : `/${ text } /` ;
305
+
306
+ if ( text === exclude ) continue ;
307
+
308
+ navBarItems . push ( { text, link } ) ;
309
+ }
310
+
311
+ return navBarItems ;
312
+
313
+ }
0 commit comments