// const sections = document.querySelectorAll("section[id]"); // // Add an event listener listening for scroll // window.addEventListener("scroll", navHighlighter); // function navHighlighter() { // // Get current scroll position // let scrollY = window.pageYOffset; // // Now we loop through sections to get height, top and ID values for each // sections.forEach(current => { // const sectionHeight = current.offsetHeight; // const sectionTop = (current.getBoundingClientRect().top + window.pageYOffset) - 50; // sectionId = current.getAttribute("id"); // if ( // scrollY > sectionTop && // scrollY <= sectionTop + sectionHeight // ){ // document.querySelector(".sidebar-nav li[id*=menu-item-" + sectionId + "]").classList.add("current-menu-item"); // } else { // document.querySelector(".sidebar-nav li[id*=menu-item-" + sectionId + "]").classList.remove("current-menu-item"); // } // }); // }