"use client" import Link from "next/link" import { usePathname } from "next/navigation" import { PAGES_NEW } from "@/lib/docs" import { showMcpDocs } from "@/lib/flags" import { getCurrentBase, getPagesFromFolder } from "@/lib/page-tree" 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: "Introduction", href: "/docs" }, { name: "Components", href: "/docs/components", }, { name: "Installation", href: "/docs/installation", }, { name: "Theming", href: "/docs/theming", }, { name: "CLI", href: "/docs/cli", }, { name: "RTL", href: "/docs/rtl", }, { name: "Skills", href: "/docs/skills", }, { name: "MCP Server", href: "/docs/mcp", }, { name: "Registry", href: "/docs/registry", }, { name: "Forms", href: "/docs/forms", }, { name: "Changelog", href: "/docs/changelog", }, ] const EXCLUDED_SECTIONS = ["installation", "dark-mode", "changelog", "rtl"] const EXCLUDED_PAGES = ["/docs", "/docs/changelog", "/docs/rtl", "/docs/new"] export function DocsSidebar({ tree, ...props }: React.ComponentProps & { tree: typeof source.pageTree }) { const pathname = usePathname() const currentBase = getCurrentBase(pathname) return (
Sections {TOP_LEVEL_SECTIONS.map(({ name, href }) => { if (!showMcpDocs && href.includes("/mcp")) { return null } return ( {name} {PAGES_NEW.includes(href) && ( )} ) })} {tree.children.map((item) => { if (EXCLUDED_SECTIONS.includes(item.$id ?? "")) { return null } return ( {item.name} {item.type === "folder" && ( {getPagesFromFolder(item, currentBase).map((page) => { if (!showMcpDocs && page.url.includes("/mcp")) { return null } if (EXCLUDED_PAGES.includes(page.url)) { return null } return ( {page.name} {PAGES_NEW.includes(page.url) && ( )} ) })} )} ) })}
) }