@@ -817,53 +817,74 @@ function processSinglePageDirectory(directory: string, baseRoute: string, rootOn
817
817
function generateAllSidebarConfigurations ( ) : DefaultTheme . SidebarMulti {
818
818
const sidebarConfig : DefaultTheme . SidebarMulti = { } ;
819
819
820
- // First add toggle mode single-page routes (most specific)
820
+ // Get all individual sidebar configurations
821
821
const toggleSidebars = getToggleModeSidebars ( ) ;
822
- Object . assign ( sidebarConfig , toggleSidebars ) ;
823
-
824
- // Then add regular single-page routes
825
822
const singlePageSidebars = getSinglePageSidebars ( ) ;
826
- Object . assign ( sidebarConfig , singlePageSidebars ) ;
827
-
828
- // Add product routes
829
823
const productSidebars = getSidebars ( 'products/' , false , 'autumn' ) ;
830
- Object . assign ( sidebarConfig , productSidebars ) ;
831
-
832
- // Add API routes
833
824
const apiSidebars = getSidebars ( 'api/' ) ;
834
- Object . assign ( sidebarConfig , apiSidebars ) ;
835
825
836
- // Add specific autumn framework routes
837
- sidebarConfig [ "/getting-started/" ] = getSidebar ( {
826
+ // Create ordered array of sidebar entries from most specific to least specific
827
+ const sidebarEntries : [ string , any ] [ ] = [ ] ;
828
+
829
+ // 1. Toggle mode single-page routes (most specific)
830
+ for ( const [ route , sidebar ] of Object . entries ( toggleSidebars ) ) {
831
+ sidebarEntries . push ( [ route , sidebar ] ) ;
832
+ }
833
+
834
+ // 2. Regular single-page routes (very specific)
835
+ for ( const [ route , sidebar ] of Object . entries ( singlePageSidebars ) ) {
836
+ sidebarEntries . push ( [ route , sidebar ] ) ;
837
+ }
838
+
839
+ // 3. Specific longer product and API routes first (autumn-collections before autumn)
840
+ const allRoutes = [
841
+ ...Object . entries ( productSidebars ) ,
842
+ ...Object . entries ( apiSidebars )
843
+ ] ;
844
+
845
+ // Sort by route length (descending) to ensure longer/more specific routes come first
846
+ allRoutes . sort ( ( [ routeA ] , [ routeB ] ) => routeB . length - routeA . length ) ;
847
+
848
+ for ( const [ route , sidebar ] of allRoutes ) {
849
+ sidebarEntries . push ( [ route , sidebar ] ) ;
850
+ }
851
+
852
+ // 4. Add specific autumn framework routes
853
+ sidebarEntries . push ( [ "/getting-started/" , getSidebar ( {
838
854
contentRoot : contentRoot + 'products/000-autumn/' ,
839
855
contentDirs : [
840
856
{ text : 'Начало работы' , dir : 'getting-started' } ,
841
857
{ text : 'Использование фреймворка' , dir : 'framework-elements' } ,
842
858
] ,
843
859
collapsed : false ,
844
860
baseLink : ""
845
- } ) ;
861
+ } ) ] ) ;
846
862
847
- sidebarConfig [ "/framework-elements/" ] = getSidebar ( {
863
+ sidebarEntries . push ( [ "/framework-elements/" , getSidebar ( {
848
864
contentRoot : contentRoot + 'products/000-autumn/' ,
849
865
contentDirs : [
850
866
{ text : 'Начало работы' , dir : 'getting-started' } ,
851
867
{ text : 'Использование фреймворка' , dir : 'framework-elements' } ,
852
868
] ,
853
869
collapsed : false ,
854
870
baseLink : ""
855
- } ) ;
871
+ } ) ] ) ;
856
872
857
- // Finally add the root catch-all (least specific)
858
- sidebarConfig [ "/" ] = getSidebar ( {
873
+ // 5. Finally add the root catch-all (least specific)
874
+ sidebarEntries . push ( [ "/" , getSidebar ( {
859
875
contentRoot : contentRoot + 'products/000-autumn/' ,
860
876
contentDirs : [
861
877
{ text : 'Начало работы' , dir : 'getting-started' } ,
862
878
{ text : 'Использование фреймворка' , dir : 'framework-elements' } ,
863
879
] ,
864
880
collapsed : false ,
865
881
baseLink : ""
866
- } ) ;
882
+ } ) ] ) ;
883
+
884
+ // Build the final configuration maintaining order
885
+ for ( const [ route , sidebar ] of sidebarEntries ) {
886
+ sidebarConfig [ route ] = sidebar ;
887
+ }
867
888
868
889
return sidebarConfig ;
869
890
}
0 commit comments