'use client' import { Feedback } from '~/components/Feedback' import { useBreakpoint } from 'common' import { Menu } from 'lucide-react' import type { HTMLAttributes } from 'react' import { useEffect, useState } from 'react' import { cn, Separator, Sheet, SheetContent, SheetHeader, SheetTrigger } from 'ui' interface TocItem extends HTMLAttributes { label: string anchor: string } export function ContributingToc({ className }: { className?: string }) { const mobileToc = useBreakpoint('lg') const [tocItems, setTocItems] = useState>([]) useEffect(() => { const headings = [ ...document.querySelectorAll( 'article.prose > h2:not(#feedback-title),h3:not(#feedback-title)' ), ] as Array const tocItems = headings .filter((heading) => !!heading.id && heading.textContent) .map((heading) => ({ label: heading.textContent!.substring(0, heading.textContent!.length - 1), // Remove ending `#` anchor: heading.id, })) setTocItems(tocItems) }, []) return mobileToc ? ( ) : (