import { component$, useSignal } from "@builder.io/qwik";
import { useContent } from "@builder.io/qwik-city";
export const Toc = component$(() => {
const { headings } = useContent();
const lastScrollIdSig = useSignal("");
return (
On this page
{(headings || []).map(({ text, id }, idx) => (
{
if (lastScrollIdSig.value !== id) {
const el = document.querySelector(`#${id}`);
if (el) {
el.scrollIntoView({ behavior: "smooth" });
lastScrollIdSig.value = id;
}
}
}}
>
-
{text}
))}
);
});