File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change 10
10
11
11
< script >
12
12
document . addEventListener ( 'DOMContentLoaded' , function ( ) {
13
- // Only sort on reference pages
14
13
if ( window . location . pathname . includes ( '/reference/' ) ) {
15
14
const navContainer = document . querySelector ( '#bd-docs-nav .bd-toc-item' ) ;
16
15
if ( navContainer ) {
17
- const lists = navContainer . querySelectorAll ( 'ul' ) ;
16
+ const topLevelItems = Array . from ( navContainer . children ) ;
18
17
19
- lists . forEach ( list => {
20
- const items = Array . from ( list . children ) ;
21
-
22
- // Sort items alphabetically
23
- items . sort ( ( a , b ) => {
24
- const textA = a . textContent . trim ( ) . toLowerCase ( ) ;
25
- const textB = b . textContent . trim ( ) . toLowerCase ( ) ;
26
- return textA . localeCompare ( textB ) ;
18
+ topLevelItems . forEach ( section => {
19
+ const subLists = section . querySelectorAll ( 'ul' ) ;
20
+ subLists . forEach ( list => {
21
+ const items = Array . from ( list . children ) ;
22
+
23
+ items . sort ( ( a , b ) => {
24
+ const textA = a . textContent . trim ( ) . toLowerCase ( ) ;
25
+ const textB = b . textContent . trim ( ) . toLowerCase ( ) ;
26
+ return textA . localeCompare ( textB ) ;
27
+ } ) ;
28
+
29
+ items . forEach ( item => list . appendChild ( item ) ) ;
27
30
} ) ;
28
-
29
- // Reattach sorted items
30
- items . forEach ( item => list . appendChild ( item ) ) ;
31
31
} ) ;
32
32
}
33
33
}
You can’t perform that action at this time.
0 commit comments