"use client" import * as React from "react" import Link, { LinkProps } from "next/link" import { useRouter } from "next/navigation" import { PAGES_NEW } from "@/lib/docs" import { showMcpDocs } from "@/lib/flags" import { source } from "@/lib/source" import { cn } from "@/lib/utils" import { Button } from "@/registry/new-york-v4/ui/button" import { Popover, PopoverContent, PopoverTrigger, } from "@/registry/new-york-v4/ui/popover" const TOP_LEVEL_SECTIONS = [ { name: "Get Started", href: "/docs" }, { name: "Components", href: "/docs/components", }, { name: "Registry", href: "/docs/registry", }, { name: "MCP Server", href: "/docs/mcp", }, { name: "Forms", href: "/docs/forms", }, { name: "Changelog", href: "/docs/changelog", }, ] export function MobileNav({ tree, items, className, }: { tree: typeof source.pageTree items: { href: string; label: string }[] className?: string }) { const [open, setOpen] = React.useState(false) return (
Menu
Home {items.map((item, index) => ( {item.label} ))}
Sections
{TOP_LEVEL_SECTIONS.map(({ name, href }) => { if (!showMcpDocs && href.includes("/mcp")) { return null } return ( {name} ) })}
{tree?.children?.map((group, index) => { if (group.type === "folder") { return (
{group.name}
{group.children.map((item) => { if (item.type === "page") { if (!showMcpDocs && item.url.includes("/mcp")) { return null } return ( {item.name}{" "} {PAGES_NEW.includes(item.url) && ( )} ) } })}
) } })}
) } function MobileLink({ href, onOpenChange, className, children, ...props }: LinkProps & { onOpenChange?: (open: boolean) => void children: React.ReactNode className?: string }) { const router = useRouter() return ( { router.push(href.toString()) onOpenChange?.(false) }} className={cn("text-2xl font-medium", className)} {...props} > {children} ) }