export function mountToc() { const observer = new IntersectionObserver((entries) => { for (const entry of entries) { const id = entry.target.getAttribute("id"); document .querySelector(`.o-toc__item[href="#${id}"]`) ?.classList.toggle("is-selected", entry.intersectionRatio > 0); } }); document.querySelectorAll("section[id]").forEach((section) => { observer.observe(section); }); }