Skip to content

Commit dd8410b

Browse files
Layout: Change currentpage to use path over HREF
1 parent dd3e3dd commit dd8410b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

assets/js/sidebar-v2.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ document.addEventListener('click', (e) => {
3838
});
3939

4040
document.addEventListener('DOMContentLoaded', () => {
41-
const currentPage = window.location.href;
42-
const match = Array.from(document.querySelectorAll('.sidebar__link')).find(
43-
(el) => el.href.includes(currentPage)
44-
);
41+
const currentPage = window.location.pathname;
42+
const match = Array.from(
43+
document.querySelectorAll('.sidebar__link--current')
44+
).find((el) => el?.id?.includes(currentPage));
4545

4646
if (match) match.scrollIntoView({ behavior: 'instant', block: 'start' });
4747
});

0 commit comments

Comments
 (0)