@@ -93,50 +93,8 @@ export default defineConfig({
93
93
] ,
94
94
collapsed : false ,
95
95
} ) ,
96
- "/annotations/" : getSidebar ( {
97
- contentRoot : contentRoot + 'products/010-annotations/' ,
98
- contentDirs : [
99
- { text : 'annotations' , dir : '.' }
100
- ] ,
101
- collapsed : false ,
102
- } ) ,
103
- "/autumn-collections/" : getSidebar ( {
104
- contentRoot : contentRoot + 'products/020-autumn-collections/' ,
105
- contentDirs : [
106
- { text : 'autumn-collections' , dir : '.' }
107
- ] ,
108
- collapsed : false ,
109
- } ) ,
110
- "/winow/" : getSidebar ( {
111
- contentRoot : contentRoot + 'products/010-winow/' ,
112
- contentDirs : [
113
- { text : 'winow' , dir : '.' }
114
- ] ,
115
- collapsed : false ,
116
- } ) ,
117
- // api
118
- "/api/autumn/" : getSidebar ( {
119
- contentRoot,
120
- contentDirs : [
121
- { text : 'autumn' , dir : 'api/000-autumn' }
122
- ] ,
123
- collapsed : false ,
124
- } ) ,
125
- "/api/annotations/" : getSidebar ( {
126
- contentRoot,
127
- contentDirs : [
128
- { text : 'annotations' , dir : 'api/010-annotations' }
129
- ] ,
130
- collapsed : false ,
131
- } ) ,
132
- "/api/autumn-collections/" : getSidebar ( {
133
- contentRoot,
134
- contentDirs : [
135
- { text : 'autumn-collections' , dir : 'api/autumn-collections' }
136
- ] ,
137
- collapsed : false ,
138
- } ) ,
139
-
96
+ ...getSidebars ( 'products/' , false , 'autumn' ) ,
97
+ ...getSidebars ( 'api/' ) ,
140
98
} ,
141
99
142
100
socialLinks : [
@@ -209,6 +167,34 @@ interface SidebarOptions {
209
167
collapsed : boolean ;
210
168
}
211
169
170
+ function getSidebars ( contentDir : string , appendSideBarWithContentDir : boolean = true , excluded : string = '' ) : DefaultTheme . SidebarMulti {
171
+
172
+ const sidebars : DefaultTheme . SidebarMulti = { } ;
173
+
174
+ const cwd = `${ process . cwd ( ) } /${ contentRoot } ` ;
175
+
176
+ const dirs = glob . sync ( `${ contentDir } /*/` , { cwd } ) . sort ( ) ;
177
+ for ( const dirIndex in dirs ) {
178
+ const dir = dirs [ dirIndex ] ;
179
+
180
+ const text = getPageName ( path . basename ( dir ) , false ) ;
181
+ const link = appendSideBarWithContentDir ? `/${ contentDir } ${ text } /` : `/${ text } /` ;
182
+
183
+ if ( text === excluded ) continue ;
184
+
185
+ sidebars [ link ] = getSidebar ( {
186
+ contentRoot : contentRoot + dir + '/' ,
187
+ contentDirs : [
188
+ { text, dir : "." }
189
+ ] ,
190
+ collapsed : false ,
191
+ } ) ;
192
+ }
193
+
194
+ return sidebars ;
195
+
196
+ }
197
+
212
198
function getSidebar ( { contentRoot, contentDirs, collapsed } : SidebarOptions ) : DefaultTheme . SidebarItem [ ] {
213
199
const sidebar : DefaultTheme . SidebarItem [ ] = [ ] ;
214
200
0 commit comments