Skip to content

Commit 3091cb5

Browse files
committed
Made changes so that only the items get sorted
1 parent 65cd394 commit 3091cb5

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

doc/_templates/sidebar-nav-bs.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@
1010

1111
<script>
1212
document.addEventListener('DOMContentLoaded', function() {
13-
// Only sort on reference pages
1413
if (window.location.pathname.includes('/reference/')) {
1514
const navContainer = document.querySelector('#bd-docs-nav .bd-toc-item');
1615
if (navContainer) {
17-
const lists = navContainer.querySelectorAll('ul');
16+
const topLevelItems = Array.from(navContainer.children);
1817

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));
2730
});
28-
29-
// Reattach sorted items
30-
items.forEach(item => list.appendChild(item));
3131
});
3232
}
3333
}

0 commit comments

Comments
 (0)