'use client' import { Menu } from 'lucide-react' import type { HTMLAttributes } from 'react' import { useEffect, useState } from 'react' import { useBreakpoint } from 'common' import { cn, Popover_Shadcn_, PopoverContent_Shadcn_, PopoverTrigger_Shadcn_ } from 'ui' interface TocItem extends HTMLAttributes { label: string anchor: string } export function ContributingToc({ className }: { className?: string }) { const mobileToc = useBreakpoint('xl') const [tocItems, setTocItems] = useState>([]) useEffect(() => { const headings = [ ...document.querySelectorAll('article.prose > h2,h3'), ] as Array const tocItems = headings .filter((heading) => !!heading.id) .map((heading) => ({ label: heading.textContent.substring(0, heading.textContent.length - 1), // Remove ending `#` anchor: heading.id, })) setTocItems(tocItems) }, []) return mobileToc ? ( ) : ( ) } function MobileToc({ items, className }: { items: Array; className?: string }) { const [open, setOpen] = useState(false) return ( {open ? 'Close table of contents' : 'Open table of contents'} ) } function TocBase({ items, className }: { items: Array; className?: string }) { return ( ) }