"use client"; import { useState, useMemo } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { List } from "lucide-react"; import { Sheet, SheetTrigger, SheetContent, SheetTitle, } from "@/components/ui/sheet"; const navigation = [ { title: "Getting Started", items: [ { title: "Introduction", href: "/docs" }, { title: "Installation", href: "/docs/installation" }, { title: "Quick Start", href: "/docs/quick-start" }, ], }, { title: "Core Concepts", items: [ { title: "Catalog", href: "/docs/catalog" }, { title: "Registry", href: "/docs/registry" }, { title: "Data Binding", href: "/docs/data-binding" }, { title: "Actions", href: "/docs/actions" }, { title: "Visibility", href: "/docs/visibility" }, { title: "Validation", href: "/docs/validation" }, ], }, { title: "Guides", items: [ { title: "AI SDK Integration", href: "/docs/ai-sdk" }, { title: "Streaming", href: "/docs/streaming" }, { title: "Code Export", href: "/docs/code-export" }, ], }, { title: "API Reference", items: [ { title: "@json-render/core", href: "/docs/api/core" }, { title: "@json-render/react", href: "/docs/api/react" }, { title: "@json-render/codegen", href: "/docs/api/codegen" }, ], }, ]; // Flatten all pages for current page lookup const allPages = navigation.flatMap((section) => section.items); export function DocsMobileNav() { const [open, setOpen] = useState(false); const pathname = usePathname(); const currentPage = useMemo(() => { const page = allPages.find((page) => page.href === pathname); return page ?? allPages[0]; }, [pathname]); return (
{currentPage?.title}
Table of Contents
); }