diff --git a/apps/docs/src/components/table-of-contents.tsx b/apps/docs/src/components/table-of-contents.tsx index 25aecb9d..b3426769 100644 --- a/apps/docs/src/components/table-of-contents.tsx +++ b/apps/docs/src/components/table-of-contents.tsx @@ -131,6 +131,24 @@ export function TableOfContents() { const currentSection = useCurrentSection(toc); + createEffect( + on( + () => currentSection(), + (currentSection) => { + if (isServer) return; + + const element = document.querySelector( + `a[data-toc-slug="${currentSection}"]`, + ); + + element?.scrollIntoView({ + behavior: "smooth", + block: "nearest", + }); + }, + ), + ); + return (