'use client' import Link from 'next/link' import { useEffect, useState } from 'react' import { ArticleHeading } from '@/types/content-types' import { cn } from '@/utils/cn' export function HeadingsMenu({ headings }: { headings: ArticleHeading[] }) { const [activeSlug, setActiveSlug] = useState('') useEffect(() => { const handleScroll = () => { let current = '' for (const { slug } of headings) { const element = document.getElementById(slug) if (element && element.getBoundingClientRect().top < 100) current = slug } setActiveSlug(current) } handleScroll() window.addEventListener('scroll', handleScroll, { passive: true }) return () => window.removeEventListener('scroll', handleScroll) }, [headings]) if (headings.length === 0) return null return (

On this page

) }