Skip to content

Commit 9c938f7

Browse files
Fix: Scroll references href now
1 parent af81be2 commit 9c938f7

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

assets/js/sidebar-v2.js

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

4040
document.addEventListener('DOMContentLoaded', () => {
41-
// need to correlate path to page rather than h1, as headers can be repeated (ie. nested1c/nested2-1 is seen the same as nested1b/nested2-1)
42-
const currentPage = document.querySelector("h1").textContent;
43-
console.log("This is a test log "+currentPage);
44-
41+
const currentPage = window.location.href;
4542
const match = Array.from(document.querySelectorAll(".sidebar__link"))
46-
.find(el => el.textContent.includes(currentPage));
43+
.find(el => el.href.includes(currentPage));
4744

48-
if (match){
49-
console.log("Matching pair? "+match)
45+
if (match)
5046
match.scrollIntoView({ behavior: "instant", block: "nearest" });
51-
}
52-
5347
});
5448

5549
const debounce = (callback, wait) => {

0 commit comments

Comments
 (0)