Remove current class from existing sidebar link before adding it to new one

This commit is contained in:
Lea Verou
2025-04-02 13:48:37 -04:00
parent 6b3edb8a56
commit ff3b3d6558

View File

@@ -12,6 +12,11 @@ const sidebar = {
// If we are on the same page, update the current link
let url = location.href.replace(/#.+$/, '');
if (url.startsWith(a.href)) {
// Remove existing current
for (let current of document.querySelectorAll('#sidebar a.current')) {
current.classList.remove('current');
}
a.classList.add('current');
}