"use client"; import { useTranslations } from "next-intl"; import { useEffect } from "react"; export function TableOfContents({ items, }: { items: { slug: string; content: string; lvl: number }[]; }) { const t = useTranslations(); const scrollToSection = (id: string) => { const scrollOffset = 80; const element = document.getElementById(id); if (element) { const elementPositionY = element.getBoundingClientRect().top + window.scrollY - scrollOffset; window.scrollTo({ top: elementPositionY, behavior: "smooth" }); history.pushState({}, "", `#${id}`); } }; useEffect(() => { if (location.hash) { scrollToSection(location.hash.substring(1)); } }, []); return (