File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,14 @@ export const useApi = () => {
1010
1111 for ( const item of tree ) {
1212 if ( item . mode !== "040000" ) continue ;
13+
14+ const sectionParts = item . path . split ( "_" ) ;
15+ const sectionOrder = sectionParts . shift ( ) ;
16+ const sectionName = sectionParts . join ( " " ) ;
17+
1318 sections [ item . path ] = {
14- title : item . path ,
19+ title : sectionName ,
20+ order : sectionOrder ,
1521 items : [ ] ,
1622 } ;
1723 }
@@ -23,17 +29,31 @@ export const useApi = () => {
2329 if ( pathParts . length < 2 ) continue ;
2430
2531 const sectionName = pathParts . shift ( ) ;
26- const topicName = pathParts . join ( "/" ) . replace ( ".md" , "" ) ;
32+ const topic = pathParts . join ( "/" ) . replace ( ".md" , "" ) ;
33+
34+ const topicParts = topic . split ( "_" ) ;
35+ const topicOrder = topicParts . shift ( ) ;
36+ const topicName = topicParts . join ( " " ) ;
2737
2838 sections [ sectionName ] . items . push ( {
2939 value : topicName ,
3040 label : topicName ,
3141 path : item . path ,
3242 url : item . url ,
43+ order : topicOrder ,
3344 } ) ;
3445 }
3546
36- return Object . values ( sections ) ;
47+ const topics = Object . values ( sections ) . map ( section => ( {
48+ ...section ,
49+ items : section . items . sort (
50+ ( a , b ) => parseInt ( a . order ) - parseInt ( b . order )
51+ ) ,
52+ } ) ) ;
53+
54+ return topics . sort (
55+ ( a , b ) => parseInt ( a . order ) - parseInt ( b . order )
56+ ) ;
3757 } , [ ] ) ;
3858
3959 const getContent = useCallback ( async ( topicUrl , successCallback ) => {
You can’t perform that action at this time.
0 commit comments