Skip to content

Commit c7e3c0f

Browse files
committed
added javascript
1 parent 43fef42 commit c7e3c0f

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

markdown/assets/a11y-nav.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
document.addEventListener("DOMContentLoaded", function () {
2+
3+
// Find sidebar navigation
4+
const menuItems = document.querySelectorAll(".wy-menu-vertical li");
5+
6+
menuItems.forEach(item => {
7+
const link = item.querySelector("a");
8+
const submenu = item.querySelector("ul");
9+
10+
if (link && submenu) {
11+
12+
// Initial state
13+
link.setAttribute("aria-expanded", item.classList.contains("current") ? "true" : "false");
14+
15+
link.addEventListener("click", function () {
16+
const expanded = link.getAttribute("aria-expanded") === "true";
17+
link.setAttribute("aria-expanded", expanded ? "false" : "true");
18+
});
19+
20+
}
21+
});
22+
23+
});

0 commit comments

Comments
 (0)