diff --git a/src/js/site.js b/src/js/site.js index 1342192..9e1d18c 100644 --- a/src/js/site.js +++ b/src/js/site.js @@ -33,7 +33,10 @@ document.addEventListener("DOMContentLoaded", () => { const observer = new IntersectionObserver(entries => { entries.forEach(entry => { const id = entry.target.previousElementSibling.id; - const menuListItem = document.querySelector(`nav li a[href="/#${id}"]`).parentElement; + const menuListItem = document.querySelector(`nav li a[href="/#${id}"]`)?.parentElement; + + if (menuListItem == null) + return; if (entry.intersectionRatio > 0) { menuListItem.classList.add("active");