@@ -14,6 +14,36 @@ export const sharedPageComponents: SharedLayout = {
14
14
} ) ,
15
15
}
16
16
17
+ const explorer = Component . Explorer ( {
18
+ sortFn : ( a , b ) => {
19
+ // Helper function to prioritise "Introduction" and "ELI5"
20
+ const priority = ( name : string ) => {
21
+ if ( name === "Introduction" ) return - 2 ; // Highest priority
22
+ if ( name === "ELI5" ) return - 1 ; // Second highest priority
23
+ return 0 ; // No priority
24
+ } ;
25
+
26
+ // Check if both are files or directories
27
+ const aIsFile = typeof a . file !== null ;
28
+ const bIsFile = typeof b . file !== null ;
29
+
30
+ // Prioritize specific filenames first
31
+ const aPriority = priority ( a . name ) ;
32
+ const bPriority = priority ( b . name ) ;
33
+
34
+ // If either has a priority, sort based on that
35
+ if ( aPriority !== bPriority ) return aPriority - bPriority ;
36
+
37
+ // If one is a file and the other is a directory, sort files first
38
+ if ( aIsFile && ! bIsFile ) return - 1 ; // a is a file, b is a directory
39
+ if ( ! aIsFile && bIsFile ) return 1 ; // a is a directory, b is a file
40
+
41
+ // If both are either files or directories, sort alphabetically
42
+ return a . name . localeCompare ( b . name ) ;
43
+ }
44
+ } ) ;
45
+
46
+
17
47
// components for pages that display a single page (e.g. a single note)
18
48
export const defaultContentPageLayout : PageLayout = {
19
49
beforeBody : [
@@ -27,7 +57,7 @@ export const defaultContentPageLayout: PageLayout = {
27
57
Component . MobileOnly ( Component . Spacer ( ) ) ,
28
58
Component . Search ( ) ,
29
59
Component . Darkmode ( ) ,
30
- Component . DesktopOnly ( Component . Explorer ( ) ) ,
60
+ Component . DesktopOnly ( explorer ) ,
31
61
] ,
32
62
right : [
33
63
Component . Graph ( ) ,
@@ -44,7 +74,7 @@ export const defaultListPageLayout: PageLayout = {
44
74
Component . MobileOnly ( Component . Spacer ( ) ) ,
45
75
Component . Search ( ) ,
46
76
Component . Darkmode ( ) ,
47
- Component . DesktopOnly ( Component . Explorer ( ) ) ,
77
+ Component . DesktopOnly ( explorer ) ,
48
78
] ,
49
79
right : [ ] ,
50
80
}
0 commit comments