"use client" import Link from "next/link" import { usePathname } from "next/navigation" import { PAGES_NEW } from "@/lib/docs" import { showMcpDocs } from "@/lib/flags" import type { source } from "@/lib/source" import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarMenu, SidebarMenuButton, SidebarMenuItem, } from "@/registry/new-york-v4/ui/sidebar" const TOP_LEVEL_SECTIONS = [ { name: "Get Started", href: "/docs" }, { name: "Components", href: "/docs/components", }, { name: "Directory", href: "/docs/directory", }, { name: "MCP Server", href: "/docs/mcp", }, { name: "Forms", href: "/docs/forms", }, { name: "Changelog", href: "/docs/changelog", }, ] const EXCLUDED_SECTIONS = ["installation", "dark-mode"] const EXCLUDED_PAGES = ["/docs", "/docs/changelog"] export function DocsSidebar({ tree, ...props }: React.ComponentProps & { tree: typeof source.pageTree }) { const pathname = usePathname() return (
Sections {TOP_LEVEL_SECTIONS.map(({ name, href }) => { if (!showMcpDocs && href.includes("/mcp")) { return null } return ( {name} ) })} {tree.children.map((item) => { if (EXCLUDED_SECTIONS.includes(item.$id ?? "")) { return null } return ( {item.name} {item.type === "folder" && ( {item.children.map((item) => { if ( !showMcpDocs && item.type === "page" && item.url?.includes("/mcp") ) { return null } return ( item.type === "page" && !EXCLUDED_PAGES.includes(item.url) && ( {item.name} {PAGES_NEW.includes(item.url) && ( )} ) ) })} )} ) })}
) }