// js/docs/DocsSidebar.jsx // IA mirrors scripts/render-docs-config.json — keep both in sync. // Top groups (Getting started, Concepts) start expanded. // Reference / Architecture / Vision / Community start collapsed // but auto-expand if the active page lives inside. const Chev = () => ( ); // IA: ~3 entries per section (Getting started runs 4 — Deploy joins the // natural Intro→Quickstart→Build→Deploy arc). Sub-pages are kept on disk // + indexed for search; just removed from sidebar nav. Re-surface by // adding back here. // // Hidden-but-on-disk: // Getting started — /docs/get-started/query-features/ // Concepts — /docs/concepts/get-and-batch-get/, /docs/concepts/windows/, // /docs/concepts/freshness/ // Vision — (none currently on disk) // // Reference / Architecture / Community sub-trees from the prior render-docs // site were nuked in commit f99a09e1; re-add a section here when their // hand-written replacements land. const SECTIONS = [ { title: 'Getting started', open: true, items: [ { label: 'Introduction', href: '/docs/' }, { label: 'Quickstart', href: '/docs/get-started/quickstart/' }, { label: 'Build a pipeline', href: '/docs/get-started/define-a-pipeline/' }, { label: 'Deploy', href: '/docs/get-started/deploy/' }, ]}, { title: 'Vision', open: true, items: [ { label: 'Why beava', href: '/docs/vision/why-beava/' }, { label: 'Non-goals and tradeoffs', href: '/docs/vision/non-goals/' }, ]}, { title: 'Concepts', open: true, items: [ { label: 'Events', href: '/docs/concepts/streams/' }, { label: 'Tables', href: '/docs/concepts/tables/' }, { label: 'Push and fetch features', href: '/docs/get-started/push-events/' }, ]}, { title: 'Community', open: false, items: [ { label: 'Roadmap', href: '/docs/community/roadmap/' }, { label: 'Contributing', href: '/docs/community/contributing/' }, { label: 'Discussions', href: 'https://github.com/beava-dev/beava/discussions', external: true }, ]}, ]; const DocsSidebar = ({ active = '' }) => { // Initial open state: per-section default; auto-expand a section if the // active page label matches one of its items. const initialOpen = {}; SECTIONS.forEach(sec => { const containsActive = active && sec.items.some(it => it.label === active); initialOpen[sec.title] = containsActive || sec.open === true; }); const [open, setOpen] = React.useState(initialOpen); const [drawerOpen, setDrawerOpen] = React.useState(false); const toggle = (title) => setOpen(prev => ({ ...prev, [title]: !prev[title] })); React.useEffect(() => { const onResize = () => { if (window.innerWidth >= 1000) setDrawerOpen(false); }; window.addEventListener('resize', onResize); return () => window.removeEventListener('resize', onResize); }, []); React.useEffect(() => { if (drawerOpen) { const prev = document.body.style.overflow; document.body.style.overflow = 'hidden'; return () => { document.body.style.overflow = prev; }; } }, [drawerOpen]); const sidebarBody = ( <> {SECTIONS.map(sec => { const isOpen = open[sec.title]; const isEmpty = sec.items.length === 0; return (