"use client" import Link from "next/link" import { usePathname } from "next/navigation" import { ArrowRightIcon } from "@radix-ui/react-icons" import { cn } from "@/lib/utils" import { ScrollArea, ScrollBar } from "@/registry/new-york/ui/scroll-area" const examples = [ { name: "Mail", href: "/examples/mail", code: "https://github.com/shadcn/ui/tree/main/apps/www/app/(app)/examples/mail", }, { name: "Dashboard", href: "/examples/dashboard", code: "https://github.com/shadcn/ui/tree/main/apps/www/app/(app)/examples/dashboard", }, { name: "Cards", href: "/examples/cards", code: "https://github.com/shadcn/ui/tree/main/apps/www/app/(app)/examples/cards", }, { name: "Tasks", href: "/examples/tasks", code: "https://github.com/shadcn/ui/tree/main/apps/www/app/(app)/examples/tasks", }, { name: "Playground", href: "/examples/playground", code: "https://github.com/shadcn/ui/tree/main/apps/www/app/(app)/examples/playground", }, { name: "Forms", href: "/examples/forms", code: "https://github.com/shadcn/ui/tree/main/apps/www/app/(app)/examples/forms", }, { name: "Music", href: "/examples/music", code: "https://github.com/shadcn/ui/tree/main/apps/www/app/(app)/examples/music", }, { name: "Authentication", href: "/examples/authentication", code: "https://github.com/shadcn/ui/tree/main/apps/www/app/(app)/examples/authentication", }, ] interface ExamplesNavProps extends React.HTMLAttributes {} export function ExamplesNav({ className, ...props }: ExamplesNavProps) { const pathname = usePathname() return (
{examples.map((example, index) => ( {example.name} ))}
) } interface ExampleCodeLinkProps { pathname: string | null } export function ExampleCodeLink({ pathname }: ExampleCodeLinkProps) { const example = examples.find((example) => pathname?.startsWith(example.href)) if (!example?.code) { return null } return ( View code ) }