Skip to content

Commit 5d94e55

Browse files
committed
Highlight active link
1 parent ab4c1ca commit 5d94e55

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

_layouts/default.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
lists = {},
7676
headers = {};
7777

78+
var locationObj = document.location.href;
79+
7880
var navUl = document.querySelectorAll('#navigation ul')[0],
7981
navLis = document.querySelectorAll('#navigation ul li');
8082

@@ -90,6 +92,11 @@
9092
continue;
9193
}
9294

95+
var link = li.childNodes[0];
96+
if (locationObj && link && locationObj.endsWith(link.getAttribute('href'))) {
97+
li.classList.add('active');
98+
}
99+
93100
if (!lists[section]) {
94101
lists[section] = [];
95102
}

0 commit comments

Comments
 (0)