'use client'; import { useEffect, useState } from 'react'; interface TocItem { id: string; text: string; depth: number; } export function PostToc() { const [items, setItems] = useState([]); useEffect(() => { const headings = Array.from( document.querySelectorAll('article h2, article h3') ); const mapped = headings .filter((el) => el.id) .map((el) => ({ id: el.id, text: el.innerText, depth: el.tagName === 'H3' ? 3 : 2 })); setItems(mapped); }, []); if (items.length === 0) return null; return ( ); }