"use client"; import { type TOCItem } from "@/types/mdx"; import { extractFlatIds, extractTOC } from "@/lib/mdx/toc"; import { cn } from "@/lib/utils"; import { useActiveItem } from "@/hooks/useActiveMenu"; export function TableOfContents({ source }: { source: string }) { const toc = extractTOC(source); const ids = extractFlatIds(toc); const activeItemId = useActiveItem(ids); if (toc.length === 0) return null; return (