Beautiful pdf components, built on Takumi and Forme. 100% Free, Zero config, one command setup.
fix: align sidebar and docs structure with termcn
Aniket-5081fbc496d4a1f
diff --git a/app/(app)/(root)/page.tsx b/app/(app)/(root)/page.tsxindex bae1008..38af276 100644--- a/app/(app)/(root)/page.tsx+++ b/app/(app)/(root)/page.tsx@@ -1,7 +1,7 @@import { CommandBox } from "@/components/command-box";import { HomeCtas } from "@/components/home-ctas";+import { PageHero } from "@/components/page-hero";import { PageTransition } from "@/components/page-transition";-import { PdfPreview } from "@/components/pdf-preview-wrapper";import { ROUTES } from "@/constants/routes";import { BreadcrumbJsonLd } from "@/seo/json-ld";@@ -13,34 +13,28 @@ const IndexPage = () => (<PageTransition><section className="container-wrapper relative"><div className="container flex flex-col items-center gap-4 py-16 text-center md:py-20 lg:py-24">- <h1 className="max-w-7xl bg-linear-to-b from-foreground via-foreground to-foreground/65 bg-clip-text text-4xl font-bold tracking-tight text-transparent sm:text-5xl md:text-6xl">- pdfcn- </h1>-- <p className="max-w-2xl text-lg text-muted-foreground sm:text-xl">- PDF components for Takumi and Forme — invoices, reports, and- primitives with live preview. Install with{" "}- <code className="rounded bg-muted px-1.5 py-0.5 text-sm">- npx shadcn add- </code>- .- </p>+ <PageHero+ description={+ <>+ Beautiful PDFs made simple with Takumi and Forme.+ <br className="hidden sm:block" />+ Install with{" "}+ <code className="rounded bg-muted px-1.5 py-0.5 text-sm">+ npx shadcn add+ </code>+ .+ </>+ }+ descriptionClassName="max-w-2xl text-lg sm:text-xl"+ title="Beautiful PDFs made simple"+ titleClassName="max-w-7xl"+ /><CommandBox className="mt-4 w-full max-w-xl" /><HomeCtas className="mt-4" /></div></section>-- <section className="container-wrapper pb-8 lg:pb-12">- <div className="container flex flex-col items-center gap-6">- <PdfPreview- base="takumi"- className="w-full max-w-2xl"- name="invoice-minimal"- />- </div>- </section></PageTransition></>);diff --git a/app/(app)/docs/[[...slug]]/page.tsx b/app/(app)/docs/[[...slug]]/page.tsxindex 9e17a3a..38a78d8 100644--- a/app/(app)/docs/[[...slug]]/page.tsx+++ b/app/(app)/docs/[[...slug]]/page.tsx@@ -3,7 +3,10 @@ import { ArrowLeftIcon, ArrowRightIcon, ArrowUpRightIcon } from "lucide-react";import Link from "next/link";import { notFound } from "next/navigation";-// import { DocsBaseSwitcher } from "@/components/docs-base-switcher";+import {+ DocsBaseSwitcher,+ getDocsBaseSwitcherProps,+} from "@/components/docs-base-switcher";import { DocsCopyPage } from "@/components/docs-copy-page";import { DocsKeyboardShortcuts } from "@/components/docs-keyboard-shortcuts";import { DocsNavLink } from "@/components/docs-nav-link";@@ -87,6 +90,7 @@ const Page = async (props: { params: Promise<{ slug?: string[] }> }) => {const { links } = doc as { links?: { doc?: string; api?: string } };const breadcrumbs = buildBreadcrumbs(params.slug ?? [], doc.title, page.url);+ const baseSwitcher = getDocsBaseSwitcherProps(params.slug);return (<>@@ -178,16 +182,9 @@ const Page = async (props: { params: Promise<{ slug?: string[] }> }) => {) : null}</div><div className="w-full flex-1 *:data-[slot=alert]:first:mt-0">- {/* {params.slug &&- params.slug[0] === "components" &&- params.slug[1] &&- params.slug[2] && (- <DocsBaseSwitcher- base={params.slug[1]}- component={params.slug.slice(2).join("/")}- className="mb-4"- />- )} */}+ {baseSwitcher && (+ <DocsBaseSwitcher {...baseSwitcher} className="mb-4" />+ )}<MdxContent components={mdxComponents} /></div></div>diff --git a/components/animated-icons/arrow-up-right.tsx b/components/animated-icons/arrow-up-right.tsxnew file mode 100644index 0000000..fceb8ec--- /dev/null+++ b/components/animated-icons/arrow-up-right.tsx@@ -0,0 +1,103 @@+"use client";++import type { Variants } from "motion/react";+import { motion, useAnimation } from "motion/react";+import type { HTMLAttributes } from "react";+import { forwardRef, useCallback, useImperativeHandle, useRef } from "react";++import { cn } from "@/lib/utils";++export interface ArrowUpRightIconHandle {+ startAnimation: () => void;+ stopAnimation: () => void;+}++interface ArrowUpRightIconProps extends HTMLAttributes<HTMLDivElement> {+ size?: number;+}++const ARROW_VARIANTS: Variants = {+ animate: {+ originX: 1,+ originY: 0,+ scale: [1, 0.85, 1],+ transition: {+ duration: 0.5,+ ease: "easeInOut",+ },+ translateX: [0, -4, 0],+ translateY: [0, 4, 0],+ },+ normal: {+ scale: 1,+ translateX: 0,+ translateY: 0,+ },+};++const ArrowUpRightIcon = forwardRef<+ ArrowUpRightIconHandle,+ ArrowUpRightIconProps+>(({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {+ const controls = useAnimation();+ const isControlledRef = useRef(false);++ useImperativeHandle(ref, () => {+ isControlledRef.current = true;+ return {+ startAnimation: () => controls.start("animate"),+ stopAnimation: () => controls.start("normal"),+ };+ });++ const handleMouseEnter = useCallback(+ (e: React.MouseEvent<HTMLDivElement>) => {+ if (!isControlledRef.current) {+ controls.start("animate");+ }+ onMouseEnter?.(e);+ },+ [controls, onMouseEnter]+ );++ const handleMouseLeave = useCallback(+ (e: React.MouseEvent<HTMLDivElement>) => {+ if (!isControlledRef.current) {+ controls.start("normal");+ }+ onMouseLeave?.(e);+ },+ [controls, onMouseLeave]+ );++ return (+ <div+ className={cn(className)}+ onMouseEnter={handleMouseEnter}+ onMouseLeave={handleMouseLeave}+ {...props}+ >+ <svg+ fill="none"+ height={size}+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="2"+ viewBox="0 0 24 24"+ width={size}+ xmlns="http://www.w3.org/2000/svg"+ >+ <motion.g animate={controls} variants={ARROW_VARIANTS}>+ <path d="M7 7H17" />+ <path d="M17 7V17" />+ <path d="M7 17L17 7" />+ </motion.g>+ </svg>+ </div>+ );+});++ArrowUpRightIcon.displayName = "ArrowUpRightIcon";++export { ArrowUpRightIcon };diff --git a/components/brand-context-menu.tsx b/components/brand-context-menu.tsxindex e72a5dc..08f7f07 100644--- a/components/brand-context-menu.tsx+++ b/components/brand-context-menu.tsx@@ -1,15 +1,16 @@"use client";-import { DownloadIcon } from "lucide-react";+import { DownloadIcon, SquareDashedIcon, TypeIcon } from "lucide-react";import { useTheme } from "next-themes";import { useCallback } from "react";import { toast } from "sonner";-import { LogoMark, getLogoMarkSVG } from "@/components/logo";+import { LogoMark, getLogoMarkSVG, getLogoTypeSVG } from "@/components/logo";import {ContextMenu,ContextMenuContent,ContextMenuItem,+ ContextMenuSeparator,ContextMenuTrigger,} from "@/components/ui/context-menu";import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard";@@ -22,40 +23,57 @@ export const BrandContextMenu = ({const { resolvedTheme } = useTheme();const { copyToClipboard } = useCopyToClipboard();- const logoMarkSvgString = getLogoMarkSVG(- resolvedTheme === "light" ? "#000" : "#fff"- );+ const color = resolvedTheme === "light" ? "#000" : "#fff";+ const logoMarkSvgString = getLogoMarkSVG(color);+ const logoTypeSvgString = getLogoTypeSVG(color);- const handleCopy = useCallback(() => {+ const handleCopyLogomark = useCallback(() => {copyToClipboard(logoMarkSvgString);- toast.success("Icon as SVG copied");+ toast.success("Logomark as SVG copied");}, [logoMarkSvgString, copyToClipboard]);- const handleDownload = useCallback(() => {- const blob = new Blob([logoMarkSvgString], {- type: "image/svg+xml;charset=utf-8",- });- const url = URL.createObjectURL(blob);- const a = document.createElement("a");- a.href = url;- a.download = "icon.svg";- a.click();- URL.revokeObjectURL(url);- toast.success("Icon as SVG downloaded");- }, [logoMarkSvgString]);+ const handleCopyLogotype = useCallback(() => {+ copyToClipboard(logoTypeSvgString);+ toast.success("Logotype as SVG copied");+ }, [logoTypeSvgString, copyToClipboard]);return (<ContextMenu><ContextMenuTrigger asChild>{children}</ContextMenuTrigger><ContextMenuContent>- <ContextMenuItem onClick={handleCopy}>+ <ContextMenuItem onClick={handleCopyLogomark}><LogoMark />- Copy as SVG+ Copy Logomark as SVG+ </ContextMenuItem>++ <ContextMenuItem onClick={handleCopyLogotype}>+ <TypeIcon />+ Copy Logotype as SVG+ </ContextMenuItem>++ <ContextMenuSeparator />++ <ContextMenuItem asChild>+ <a+ href="https://shadcn-labs.com/brand"+ target="_blank"+ rel="noopener noreferrer"+ >+ <SquareDashedIcon />+ Brand Guidelines+ </a></ContextMenuItem>- <ContextMenuItem onClick={handleDownload}>- <DownloadIcon /> Download as SVG+ <ContextMenuItem asChild>+ <a+ href="https://shadcn-labs.com/shadcn-labs-brand.zip"+ target="_blank"+ rel="noopener noreferrer"+ >+ <DownloadIcon />+ Download Brand Assets+ </a></ContextMenuItem></ContextMenuContent></ContextMenu>diff --git a/components/docs-base-switcher.tsx b/components/docs-base-switcher.tsxindex abc3efd..35f99e8 100644--- a/components/docs-base-switcher.tsx+++ b/components/docs-base-switcher.tsx@@ -1,28 +1,67 @@import Link from "next/link";import { cn } from "@/lib/utils";-import { BASES, getBase } from "@/registry/bases";+import { BASE_NAMES, BASES, getBase } from "@/registry/bases";import type { BaseName } from "@/registry/bases";+type DocsBaseSwitcherSection = "components" | "blocks";++const DOCS_BASE_SWITCHER_SECTIONS = new Set<DocsBaseSwitcherSection>([+ "components",+ "blocks",+]);++const isDocsBaseSwitcherSection = (+ section: string+): section is DocsBaseSwitcherSection =>+ DOCS_BASE_SWITCHER_SECTIONS.has(section as DocsBaseSwitcherSection);++export const getDocsBaseSwitcherProps = (+ slug: string[] | undefined+): {+ section: DocsBaseSwitcherSection;+ base: string;+ slug?: string;+} | null => {+ if (!slug || slug.length < 2) {+ return null;+ }++ const [section, base, ...rest] = slug;++ if (+ !BASE_NAMES.includes(base as BaseName) ||+ !isDocsBaseSwitcherSection(section)+ ) {+ return null;+ }++ if (!rest.length) {+ return null;+ }++ return { base, section, slug: rest.join("/") };+};+export const DocsBaseSwitcher = ({base,- component,+ slug,+ section,className,- kind = "components",}: {base: string;- component: string;+ slug?: string;+ section: DocsBaseSwitcherSection;className?: string;- kind?: "components" | "blocks" | string;}) => {- const activeBase = getBase(base as BaseName);+ const activeBase = getBase(base as (typeof BASES)[number]["name"]);return (<div className={cn("inline-flex w-full items-center gap-6", className)}>{BASES.map((baseItem) => (<Linkkey={baseItem.name}- href={`/docs/${kind}/${baseItem.name}/${component}`}+ href={`/docs/${section}/${baseItem.name}${slug ? `/${slug}` : ""}`}data-active={base === baseItem.name}className="relative inline-flex items-center justify-center gap-1 pt-1 pb-0.5 text-base font-medium text-muted-foreground transition-colors after:absolute after:inset-x-0 after:bottom-[-4px] after:h-0.5 after:bg-foreground after:opacity-0 after:transition-opacity hover:text-foreground data-[active=true]:text-foreground data-[active=true]:after:opacity-100">diff --git a/components/docs-sidebar.tsx b/components/docs-sidebar.tsxindex b2b9585..882ceb6 100644--- a/components/docs-sidebar.tsx+++ b/components/docs-sidebar.tsx@@ -13,21 +13,48 @@ import {SidebarMenuButton,SidebarMenuItem,} from "@/components/ui/sidebar";+import { TOP_LEVEL_SECTIONS } from "@/constants/nav";import { ROUTES } from "@/constants/routes";-import { EXCLUDED_SECTIONS, isComponentsFolder } from "@/lib/docs";-import { getAllPagesFromFolder, getPagesFromFolder } from "@/lib/page-tree";+import {+ getDocsSidebarPanel,+ isBlocksFolder,+ isComponentsFolder,+} from "@/lib/docs";+import {+ findBaseFolder,+ getAllPagesFromFolder,+ getCurrentBase,+ getTreeGroups,+} from "@/lib/page-tree";+import type { PageTreeFolder } from "@/lib/page-tree";import type { source } from "@/lib/source";-const TOP_LEVEL_SECTIONS = [- { href: ROUTES.DOCS, name: "Introduction" },- { href: ROUTES.DOCS_INSTALLATION, name: "Installation" },- { href: ROUTES.DOCS_COMPONENTS, name: "Components" },- { href: ROUTES.LLMS, name: "llms.txt" },-];-const MENU_BUTTON_CLS ="relative h-[30px] w-fit overflow-visible border border-transparent text-[0.8rem] font-medium after:absolute after:inset-x-0 after:-inset-y-1 after:z-0 after:rounded-md data-[active=true]:border-accent data-[active=true]:bg-accent 3xl:fixed:w-full 3xl:fixed:max-w-48";+const SidebarMenuItemLink = ({+ href,+ isActive,+ children,+}: {+ href: string;+ isActive: boolean;+ children: React.ReactNode;+}) => (+ <SidebarMenuItem>+ <SidebarMenuButton+ asChild+ className={MENU_BUTTON_CLS}+ isActive={isActive}+ >+ <Link href={href}>+ <span className="absolute inset-0 flex w-(--sidebar-menu-width) bg-transparent" />+ {children}+ </Link>+ </SidebarMenuButton>+ </SidebarMenuItem>+);+const SidebarPageGroup = ({label,pages,@@ -49,18 +76,13 @@ const SidebarPageGroup = ({<SidebarGroupContent><SidebarMenu>{pages.map((page) => (- <SidebarMenuItem key={page.url}>- <SidebarMenuButton- asChild- className={MENU_BUTTON_CLS}- isActive={page.url === pathname}- >- <Link href={page.url}>- <span className="absolute inset-0 flex w-(--sidebar-menu-width) bg-transparent" />- {page.name}- </Link>- </SidebarMenuButton>- </SidebarMenuItem>+ <SidebarMenuItemLink+ key={page.url}+ href={page.url}+ isActive={page.url === pathname}+ >+ {page.name}+ </SidebarMenuItemLink>))}</SidebarMenu></SidebarGroupContent>@@ -68,11 +90,87 @@ const SidebarPageGroup = ({);};+interface SidebarPanelProps {+ currentBase: string;+ pathname: string;+ tree: typeof source.pageTree;+}++const findTopLevelFolder = (+ tree: typeof source.pageTree,+ predicate: (folder: PageTreeFolder) => boolean+) =>+ tree.children.find(+ (item): item is PageTreeFolder => item.type === "folder" && predicate(item)+ );++const ComponentsSidebarPanel = ({+ currentBase,+ pathname,+ tree,+}: SidebarPanelProps) => {+ const folder = findTopLevelFolder(tree, isComponentsFolder);+ if (!folder) {+ return null;+ }++ // Get pages from the base folder+ const baseFolder = findBaseFolder(folder, currentBase);+ const pages = (baseFolder ? getAllPagesFromFolder(baseFolder) : getAllPagesFromFolder(folder))+ .filter((page) => !page.url.endsWith("/components") && !page.url.endsWith("/components/"))+ .map((page) => ({ url: page.url, name: page.name }));++ return (+ <SidebarPageGroup+ label="Components"+ pages={pages}+ pathname={pathname}+ />+ );+};++const BlocksSidebarPanel = ({+ currentBase,+ pathname,+ tree,+}: SidebarPanelProps) => {+ const folder = findTopLevelFolder(tree, isBlocksFolder);+ if (!folder) {+ return null;+ }++ const pages = getAllPagesFromFolder(folder)+ .filter((page) => !page.url.endsWith("/blocks") && !page.url.endsWith("/blocks/"))+ .map((page) => ({ url: page.url, name: page.name }));++ return (+ <SidebarPageGroup+ label="Blocks"+ pages={pages}+ pathname={pathname}+ />+ );+};+export const DocsSidebar = ({tree,...props}: React.ComponentProps<typeof Sidebar> & { tree: typeof source.pageTree }) => {const pathname = usePathname();+ const currentBase = getCurrentBase(pathname);+ const panel = getDocsSidebarPanel(pathname);+ const treeGroups = getTreeGroups(tree, currentBase);++ const renderCatalogPanel = () => {+ const panelProps = { currentBase, pathname, tree };+ if (panel === "components") {+ return <ComponentsSidebarPanel {...panelProps} />;+ }+ if (panel === "blocks") {+ return <BlocksSidebarPanel {...panelProps} />;+ }+ return null;+ };return (<Sidebar@@ -91,49 +189,31 @@ export const DocsSidebar = ({<SidebarGroupContent><SidebarMenu>{TOP_LEVEL_SECTIONS.map(({ name, href }) => (- <SidebarMenuItem key={name}>- <SidebarMenuButton- asChild- className={MENU_BUTTON_CLS}- isActive={- href === ROUTES.DOCS- ? pathname === href- : pathname.startsWith(href)- }- >- <Link href={href}>- <span className="absolute inset-0 flex w-(--sidebar-menu-width) bg-transparent" />- {name}- </Link>- </SidebarMenuButton>- </SidebarMenuItem>+ <SidebarMenuItemLink+ key={name}+ href={href}+ isActive={+ href === ROUTES.DOCS+ ? pathname === href+ : pathname.startsWith(href)+ }+ >+ {name}+ </SidebarMenuItemLink>))}</SidebarMenu></SidebarGroupContent></SidebarGroup>- {tree.children.map((item) => {- if (item.type !== "folder") {- return null;- }- if (EXCLUDED_SECTIONS.has(item.$id ?? "")) {- return null;- }-- const pages = isComponentsFolder(item)- ? getAllPagesFromFolder(item).filter(- (page) => page.url !== ROUTES.DOCS_COMPONENTS- )- : getPagesFromFolder(item);-- return (- <SidebarPageGroup- key={item.$id}- label={item.name}- pages={pages}- pathname={pathname}- />- );- })}+ {panel+ ? renderCatalogPanel()+ : treeGroups.map((group) => (+ <SidebarPageGroup+ key={group.label}+ label={group.label}+ pages={group.pages}+ pathname={pathname}+ />+ ))}<div className="from-background via-background/80 to-background/50 sticky -bottom-1 z-10 h-16 shrink-0 bg-linear-to-t blur-xs" /></SidebarContent></Sidebar>diff --git a/components/labs-nav.tsx b/components/labs-nav.tsxnew file mode 100644index 0000000..b727d3f--- /dev/null+++ b/components/labs-nav.tsx@@ -0,0 +1,258 @@+"use client";++import { ChevronDownIcon } from "lucide-react";+import { useState } from "react";++import type { ArrowUpRightIconHandle } from "@/components/animated-icons/arrow-up-right";+import { ArrowUpRightIcon } from "@/components/animated-icons/arrow-up-right";+import { Button } from "@/components/ui/button";+import {+ NavigationMenu,+ NavigationMenuContent,+ NavigationMenuItem,+ NavigationMenuLink,+ NavigationMenuList,+ NavigationMenuTrigger,+} from "@/components/ui/navigation-menu";+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/components/ui/popover";+import { LABS_NAV_SECTIONS } from "@/constants/nav";+import type { LabsNavLink as LabsNavLinkItem } from "@/constants/nav";+import { SITE } from "@/constants/site";+import { useIconAnimation } from "@/hooks/use-icon-animation";+import { cn } from "@/lib/utils";++type SectionId = (typeof LABS_NAV_SECTIONS)[number]["id"];++const SECTION_WIDTH: Partial<Record<SectionId, string>> = {+ registries: "w-40",+ skills: "w-72",+};++interface LinkAnimationProps {+ onMouseEnter: () => void;+ onMouseLeave: () => void;+}++const SectionTitle = ({ children }: { children: React.ReactNode }) => (+ <div className="text-sm font-medium text-muted-foreground">{children}</div>+);++const ExternalLinkLabel = ({+ name,+ iconRef,+ size = 16,+ iconClassName,+}: {+ name: string;+ iconRef: React.RefObject<ArrowUpRightIconHandle | null>;+ size?: number;+ iconClassName?: string;+}) => (+ <>+ {name}+ <ArrowUpRightIcon+ ref={iconRef}+ size={size}+ className={cn("inline-flex shrink-0", iconClassName)}+ />+ </>+);++const LabsNavLink = ({+ item,+ iconSize = 16,+ children,+}: {+ item: LabsNavLinkItem;+ iconSize?: number;+ children: (+ props: LinkAnimationProps & { label: React.ReactNode }+ ) => React.ReactNode;+}) => {+ const { iconRef, onMouseEnter, onMouseLeave } =+ useIconAnimation<ArrowUpRightIconHandle>();++ return children({+ label: (+ <ExternalLinkLabel name={item.name} iconRef={iconRef} size={iconSize} />+ ),+ onMouseEnter,+ onMouseLeave,+ });+};++const DesktopSection = ({+ title,+ items,+ className,+}: {+ title: string;+ items: readonly LabsNavLinkItem[];+ className?: string;+}) => (+ <div className={cn("flex flex-col gap-3", className)}>+ <SectionTitle>{title}</SectionTitle>+ <ul className="flex flex-col gap-1">+ {items.map((item) => (+ <li key={item.href} className="w-full">+ <LabsNavLink item={item}>+ {({ label, onMouseEnter, onMouseLeave }) => (+ <NavigationMenuLink+ href={item.href}+ target="_blank"+ rel="noopener noreferrer"+ className={cn(+ "flex w-full flex-row items-center gap-1 whitespace-nowrap rounded-none",+ "bg-transparent p-0 text-base font-normal leading-normal",+ "underline-offset-4 decoration-muted-foreground/50 decoration-1",+ "hover:bg-transparent hover:underline focus:bg-transparent focus:underline",+ "data-[active=true]:bg-transparent"+ )}+ onMouseEnter={onMouseEnter}+ onMouseLeave={onMouseLeave}+ >+ {label}+ </NavigationMenuLink>+ )}+ </LabsNavLink>+ </li>+ ))}+ </ul>+ </div>+);++const LabsNavMobile = () => {+ const [open, setOpen] = useState(false);+ const close = () => setOpen(false);++ return (+ <Popover open={open} onOpenChange={setOpen}>+ <PopoverTrigger asChild>+ <Button+ variant="ghost"+ size="sm"+ className="gap-1 text-base hover:bg-transparent focus-visible:bg-transparent data-[state=open]:bg-transparent dark:hover:bg-transparent"+ >+ {SITE.NAME}+ <ChevronDownIcon+ className={cn(+ "size-3 transition-transform duration-200",+ open && "rotate-180"+ )}+ strokeWidth={2.5}+ />+ </Button>+ </PopoverTrigger>+ <PopoverContent+ className="bg-background/90 no-scrollbar h-(--radix-popper-available-height) w-(--radix-popper-available-width) overflow-y-auto rounded-none border-none p-0 shadow-none backdrop-blur duration-100"+ align="start"+ side="bottom"+ alignOffset={-16}+ sideOffset={14}+ >+ <div className="flex flex-col gap-12 overflow-auto px-6 py-6">+ {LABS_NAV_SECTIONS.map((section) => (+ <div key={section.id} className="flex flex-col gap-4">+ <SectionTitle>{section.title}</SectionTitle>+ <div className="flex flex-col gap-3">+ {section.items.map((item) => (+ <LabsNavLink key={item.href} item={item} iconSize={24}>+ {({ label, onMouseEnter, onMouseLeave }) => (+ <a+ target="_blank"+ rel="noopener noreferrer"+ href={item.href}+ className="inline-flex items-center gap-1 text-2xl font-medium"+ onClick={close}+ onMouseEnter={onMouseEnter}+ onMouseLeave={onMouseLeave}+ >+ {label}+ </a>+ )}+ </LabsNavLink>+ ))}+ </div>+ </div>+ ))}+ </div>+ </PopoverContent>+ </Popover>+ );+};++const LabsNavDesktop = () => {+ const [value, setValue] = useState("");++ return (+ <>+ {value ? (+ <button+ type="button"+ aria-label="Close menu"+ className="fixed inset-x-0 top-(--header-height) bottom-0 z-20 cursor-default bg-background/60"+ onClick={() => setValue("")}+ />+ ) : null}+ <NavigationMenu+ value={value}+ onValueChange={setValue}+ viewport={false}+ delayDuration={0}+ className="z-50 max-w-none justify-start"+ >+ <NavigationMenuList className="justify-start">+ <NavigationMenuItem value="labs">+ <NavigationMenuTrigger+ className={cn(+ "h-auto gap-1 bg-transparent px-3 py-1.5 text-base font-medium",+ "hover:bg-transparent hover:text-foreground focus:bg-transparent focus:text-foreground",+ "data-[state=open]:bg-transparent data-[state=open]:text-foreground",+ "data-[state=open]:hover:bg-transparent data-[state=open]:focus:bg-transparent"+ )}+ >+ {SITE.NAME}+ </NavigationMenuTrigger>+ <NavigationMenuContent+ className={cn(+ "fixed inset-x-0 top-(--header-height) z-30 w-screen bg-background p-0",+ "shadow-[0_1px_0_0_var(--border)]",+ "before:absolute before:inset-x-0 before:-top-3 before:h-3 before:content-['']",+ "data-[motion^=from-]:animate-none data-[motion^=to-]:animate-none",+ "data-[state=closed]:hidden md:fixed md:w-screen dark:bg-black"+ )}+ >+ <div className="container-wrapper px-6">+ <div className="flex gap-8 py-4 pl-3">+ {LABS_NAV_SECTIONS.map((section) => (+ <DesktopSection+ key={section.id}+ title={section.title}+ items={section.items}+ className={SECTION_WIDTH[section.id] ?? "w-44"}+ />+ ))}+ </div>+ </div>+ </NavigationMenuContent>+ </NavigationMenuItem>+ </NavigationMenuList>+ </NavigationMenu>+ </>+ );+};++export const LabsNav = () => (+ <>+ <div className="lg:hidden">+ <LabsNavMobile />+ </div>+ <div className="hidden lg:block">+ <LabsNavDesktop />+ </div>+ </>+);diff --git a/components/logo.tsx b/components/logo.tsxindex 302de96..213091a 100644--- a/components/logo.tsx+++ b/components/logo.tsx@@ -22,6 +22,30 @@ export const LogoMark = ({</svg>);+export const LogoType = ({+ className,+ ...props+}: React.ComponentProps<"svg">) => (+ <svg+ viewBox="0 0 120 24"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ className={cn("h-4 w-auto fill-foreground", className)}+ {...props}+ >+ <text+ x="0"+ y="18"+ fontFamily="system-ui, sans-serif"+ fontSize="18"+ fontWeight="600"+ fill="currentColor"+ >+ pdfcn+ </text>+ </svg>+);+export const getLogoMarkSVG = (color: string) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="${color}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z"/>@@ -30,3 +54,9 @@ export const getLogoMarkSVG = (color: string) => `<path d="m7.5 4.27 9 5.15"/></svg>`;++export const getLogoTypeSVG = (color: string) => `+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 24" fill="none">+ <text x="0" y="18" font-family="system-ui, sans-serif" font-size="18" font-weight="600" fill="${color}">pdfcn</text>+ </svg>+`;diff --git a/components/mobile-nav.tsx b/components/mobile-nav.tsxindex 394cf8b..cf9c3b5 100644--- a/components/mobile-nav.tsx+++ b/components/mobile-nav.tsx@@ -3,8 +3,8 @@import type { Root as PageTreeRoot } from "fumadocs-core/page-tree";import type { LinkProps } from "next/link";import Link from "next/link";-import { useRouter } from "next/navigation";-import { useCallback, useState } from "react";+import { usePathname, useRouter } from "next/navigation";+import { useCallback, useMemo, useState } from "react";import { Button } from "@/components/ui/button";import {@@ -12,10 +12,16 @@ import {PopoverContent,PopoverTrigger,} from "@/components/ui/popover";+import { TOP_LEVEL_SECTIONS } from "@/constants/nav";import { ROUTES } from "@/constants/routes";import { useFeedback } from "@/hooks/use-feedback";-import { EXCLUDED_SECTIONS, isComponentsFolder } from "@/lib/docs";-import { getAllPagesFromFolder, getPagesFromFolder } from "@/lib/page-tree";+import { getDocsSidebarPanel, isBlocksFolder, isComponentsFolder } from "@/lib/docs";+import {+ getAllPagesFromFolder,+ getCurrentBase,+ getTreeGroups,+} from "@/lib/page-tree";+import type { PageTreeFolder } from "@/lib/page-tree";import { cn } from "@/lib/utils";const MobileLink = ({@@ -76,6 +82,66 @@ const MobileNavGroup = ({);};+interface MobilePanelProps {+ currentBase: string;+ setOpen: (open: boolean) => void;+ tree: PageTreeRoot;+}++const findTopLevelFolder = (+ tree: PageTreeRoot,+ predicate: (folder: PageTreeFolder) => boolean+) =>+ tree.children.find(+ (item): item is PageTreeFolder => item.type === "folder" && predicate(item)+ );++const ComponentsMobilePanel = ({+ currentBase,+ setOpen,+ tree,+}: MobilePanelProps) => {+ const folder = findTopLevelFolder(tree, isComponentsFolder);+ if (!folder) {+ return null;+ }++ const pages = getAllPagesFromFolder(folder)+ .filter((page) => page.url !== ROUTES.DOCS_COMPONENTS)+ .map((page) => ({ url: page.url, name: page.name }));++ return (+ <MobileNavGroup+ label="Components"+ pages={pages}+ setOpen={setOpen}+ />+ );+};++const BlocksMobilePanel = ({+ currentBase,+ setOpen,+ tree,+}: MobilePanelProps) => {+ const folder = findTopLevelFolder(tree, isBlocksFolder);+ if (!folder) {+ return null;+ }++ const pages = getAllPagesFromFolder(folder)+ .filter((page) => page.url !== ROUTES.DOCS_BLOCKS)+ .map((page) => ({ url: page.url, name: page.name }));++ return (+ <MobileNavGroup+ label="Blocks"+ pages={pages}+ setOpen={setOpen}+ />+ );+};+export const MobileNav = ({items,tree,@@ -86,6 +152,24 @@ export const MobileNav = ({className?: string;}) => {const [open, setOpen] = useState(false);+ const pathname = usePathname();+ const currentBase = getCurrentBase(pathname);+ const panel = getDocsSidebarPanel(pathname);+ const treeGroups = useMemo(+ () => getTreeGroups(tree, currentBase),+ [tree, currentBase]+ );++ const renderCatalogPanel = () => {+ const panelProps = { currentBase, setOpen, tree };+ if (panel === "components") {+ return <ComponentsMobilePanel {...panelProps} />;+ }+ if (panel === "blocks") {+ return <BlocksMobilePanel {...panelProps} />;+ }+ return null;+ };return (<Popover sounds open={open} onOpenChange={setOpen}>@@ -93,7 +177,7 @@ export const MobileNav = ({<Buttonvariant="ghost"className={cn(- "extend-touch-target h-8 touch-manipulation items-center justify-start gap-2.5 !p-0 hover:bg-transparent focus-visible:bg-transparent focus-visible:ring-0 active:bg-transparent dark:hover:bg-transparent",+ "extend-touch-target h-8 touch-manipulation items-center justify-start !p-0 hover:bg-transparent focus-visible:bg-transparent focus-visible:ring-0 active:bg-transparent dark:hover:bg-transparent",className)}>@@ -114,9 +198,6 @@ export const MobileNav = ({</div><span className="sr-only">Toggle Menu</span></div>- <span className="flex h-8 items-center text-lg leading-none font-medium">- Menu- </span></Button></PopoverTrigger><PopoverContent@@ -127,48 +208,45 @@ export const MobileNav = ({sideOffset={14}><div className="flex flex-col gap-12 overflow-auto px-6 py-6">+ <div className="flex flex-col gap-3">+ <MobileLink href={ROUTES.HOME} onOpenChange={setOpen}>+ Home+ </MobileLink>+ {items.map((item) => (+ <MobileLink+ key={item.href}+ href={item.href}+ onOpenChange={setOpen}+ >+ {item.label}+ </MobileLink>+ ))}+ </div><div className="flex flex-col gap-4">- <div className="text-muted-foreground text-sm font-medium">- Menu+ <div className="text-sm font-medium text-muted-foreground">+ Sections</div><div className="flex flex-col gap-3">- <MobileLink href={ROUTES.HOME} onOpenChange={setOpen}>- Home- </MobileLink>- {items.map((item) => (- <MobileLink- key={item.href}- href={item.href}- onOpenChange={setOpen}- >- {item.label}+ {TOP_LEVEL_SECTIONS.map(({ name, href }) => (+ <MobileLink key={name} href={href} onOpenChange={setOpen}>+ {name}</MobileLink>))}</div></div>- {tree.children.map((item) => {- if (item.type !== "folder") {- return null;- }- if (EXCLUDED_SECTIONS.has(item.$id ?? "")) {- return null;- }-- const pages = isComponentsFolder(item)- ? getAllPagesFromFolder(item).filter(- (page) => page.url !== ROUTES.DOCS_COMPONENTS- )- : getPagesFromFolder(item);-- return (- <MobileNavGroup- key={item.$id}- label={item.name}- pages={pages}- setOpen={setOpen}- />- );- })}+ {panel+ ? renderCatalogPanel()+ : treeGroups.map((group) => (+ <MobileNavGroup+ key={group.label}+ label={group.label}+ pages={group.pages.map((p) => ({+ name: p.name,+ url: p.url,+ }))}+ setOpen={setOpen}+ />+ ))}</div></PopoverContent></Popover>diff --git a/components/page-hero.tsx b/components/page-hero.tsxnew file mode 100644index 0000000..d79a2b5--- /dev/null+++ b/components/page-hero.tsx@@ -0,0 +1,44 @@+import type { ReactNode } from "react";++import { Announcement } from "@/components/announcement";+import { cn } from "@/lib/utils";++interface PageHeroProps {+ description: ReactNode;+ descriptionClassName?: string;+ showAnnouncement?: boolean;+ title: ReactNode;+ titleClassName?: string;+}++export const PageHero = ({+ description,+ descriptionClassName,+ showAnnouncement = false,+ title,+ titleClassName,+}: PageHeroProps) => (+ <header className="relative flex flex-col items-center gap-4 text-center">+ {showAnnouncement && (+ <div className="absolute bottom-full left-1/2 mb-4 flex -translate-x-1/2">+ <Announcement />+ </div>+ )}+ <h1+ className={cn(+ "from-foreground via-foreground to-foreground/65 bg-linear-to-b bg-clip-text text-4xl font-bold tracking-tight text-transparent sm:text-5xl md:text-6xl",+ titleClassName+ )}+ >+ {title}+ </h1>+ <p+ className={cn(+ "text-muted-foreground max-w-lg text-base leading-relaxed text-balance",+ descriptionClassName+ )}+ >+ {description}+ </p>+ </header>+);diff --git a/components/site-header.tsx b/components/site-header.tsxindex b0512cf..3d2ed28 100644--- a/components/site-header.tsx+++ b/components/site-header.tsx@@ -2,21 +2,21 @@ import Link from "next/link";import { BrandContextMenu } from "@/components/brand-context-menu";import { CommandMenu } from "@/components/command-menu";+import { LabsNav } from "@/components/labs-nav";import { LogoMark } from "@/components/logo";import { MainNav } from "@/components/main-nav";import { MobileNav } from "@/components/mobile-nav";-import { ModeSwitcher } from "@/components/mode-switcher";import { NavItemGithub } from "@/components/nav-item-github";import { SiteSettings } from "@/components/site-settings";import { SponsorLink } from "@/components/sponsor-link";import { Button } from "@/components/ui/button";import { ROUTES } from "@/constants/routes";-import { SITE } from "@/constants/site";import { source } from "@/lib/source";const navItems = [{ href: ROUTES.DOCS, label: "Docs" },{ href: ROUTES.DOCS_COMPONENTS, label: "Components" },+ { href: ROUTES.DOCS_BLOCKS, label: "Blocks" },];export const SiteHeader = () => (@@ -24,35 +24,41 @@ export const SiteHeader = () => (className="bg-background sticky top-0 z-50 w-full"style={{ viewTransitionName: "site-header" }}>- <div className="container-wrapper 3xl:fixed:px-0 px-6">- <div className="3xl:fixed:container flex h-(--header-height) items-center gap-2">+ <div className="container-wrapper 3xl:fixed:px-0 relative px-6">+ <div className="3xl:fixed:container relative flex h-(--header-height) items-center"><MobileNavitems={navItems}tree={source.pageTree}- className="flex lg:hidden"+ className="flex lg:hidden mr-2"/>- <BrandContextMenu>- <Button- asChild- variant="ghost"- size="icon"- className="hidden size-8 lg:flex"- sound="click"- >- <Link href={ROUTES.HOME} transitionTypes={["nav-back"]}>- <LogoMark className="size-5" />- <span className="sr-only">{SITE.NAME}</span>- </Link>- </Button>- </BrandContextMenu>+ <div className="flex items-center">+ <BrandContextMenu>+ <Button+ asChild+ variant="ghost"+ size="icon-sm"+ className="hover:bg-transparent focus-visible:bg-transparent dark:hover:bg-transparent lg:size-9"+ sound="click"+ >+ <Link+ href="https://shadcn-labs.com"+ target="_blank"+ rel="noopener noreferrer"+ >+ <LogoMark className="size-5" />+ </Link>+ </Button>+ </BrandContextMenu>+ <span className="text-muted-foreground/50 ml-1">/</span>+ <LabsNav />+ </div><MainNav items={navItems} className="hidden lg:flex" />- <div className="ml-auto flex items-center gap-2 md:flex-1 md:justify-end">+ <div className="ml-auto flex items-center gap-1 md:gap-2 md:flex-1 md:justify-end"><div className="hidden w-full flex-1 md:flex md:w-auto md:flex-none"><CommandMenu navItems={navItems} tree={source.pageTree} /></div><NavItemGithub /><SponsorLink />- <ModeSwitcher /><SiteSettings /></div></div>diff --git a/components/ui/navigation-menu.tsx b/components/ui/navigation-menu.tsxnew file mode 100644index 0000000..84918c1--- /dev/null+++ b/components/ui/navigation-menu.tsx@@ -0,0 +1,150 @@+import { cva } from "class-variance-authority";+import { ChevronDownIcon } from "lucide-react";+import { NavigationMenu as NavigationMenuPrimitive } from "radix-ui";++import { cn } from "@/lib/utils";++const navigationMenuTriggerStyle = cva(+ "group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-[color,box-shadow] outline-none hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=open]:bg-accent/50 data-[state=open]:text-accent-foreground data-[state=open]:hover:bg-accent data-[state=open]:focus:bg-accent"+);++const NavigationMenuViewport = ({+ className,+ ...props+}: React.ComponentProps<typeof NavigationMenuPrimitive.Viewport>) => (+ <div className="absolute top-full left-1/2 isolate z-50 w-screen -translate-x-1/2">+ <NavigationMenuPrimitive.Viewport+ data-slot="navigation-menu-viewport"+ className={cn(+ "relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full origin-top overflow-hidden rounded-md border bg-popover text-popover-foreground shadow duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:slide-in-from-top-2 md:w-[var(--radix-navigation-menu-viewport-width)]",+ className+ )}+ {...props}+ />+ </div>+);++const NavigationMenu = ({+ className,+ children,+ viewport = true,+ viewportClassName,+ ...props+}: React.ComponentProps<typeof NavigationMenuPrimitive.Root> & {+ viewport?: boolean;+ viewportClassName?: string;+}) => (+ <NavigationMenuPrimitive.Root+ data-slot="navigation-menu"+ data-viewport={viewport}+ className={cn(+ "group/navigation-menu relative flex max-w-max flex-1 items-center justify-center",+ className+ )}+ {...props}+ >+ {children}+ {viewport && <NavigationMenuViewport className={viewportClassName} />}+ </NavigationMenuPrimitive.Root>+);++const NavigationMenuList = ({+ className,+ ...props+}: React.ComponentProps<typeof NavigationMenuPrimitive.List>) => (+ <NavigationMenuPrimitive.List+ data-slot="navigation-menu-list"+ className={cn(+ "group flex flex-1 list-none items-center justify-center gap-1",+ className+ )}+ {...props}+ />+);++const NavigationMenuItem = ({+ className,+ ...props+}: React.ComponentProps<typeof NavigationMenuPrimitive.Item>) => (+ <NavigationMenuPrimitive.Item+ data-slot="navigation-menu-item"+ className={cn("relative", className)}+ {...props}+ />+);++const NavigationMenuTrigger = ({+ className,+ children,+ ...props+}: React.ComponentProps<typeof NavigationMenuPrimitive.Trigger>) => (+ <NavigationMenuPrimitive.Trigger+ data-slot="navigation-menu-trigger"+ className={cn(navigationMenuTriggerStyle(), "group", className)}+ {...props}+ >+ {children}{" "}+ <ChevronDownIcon+ className="relative top-[1px] ml-1 size-3 transition duration-300 group-data-[state=open]:rotate-180"+ strokeWidth={2.5}+ aria-hidden="true"+ />+ </NavigationMenuPrimitive.Trigger>+);++const NavigationMenuContent = ({+ className,+ ...props+}: React.ComponentProps<typeof NavigationMenuPrimitive.Content>) => (+ <NavigationMenuPrimitive.Content+ data-slot="navigation-menu-content"+ className={cn(+ "top-0 left-0 w-full p-2 pr-2.5 data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 data-[motion^=from-]:animate-in data-[motion^=from-]:fade-in data-[motion^=to-]:animate-out data-[motion^=to-]:fade-out md:absolute md:w-auto",+ "group-data-[viewport=false]/navigation-menu:bg-popover group-data-[viewport=false]/navigation-menu:text-popover-foreground group-data-[viewport=false]/navigation-menu:data-[state=closed]:animate-none group-data-[viewport=false]/navigation-menu:data-[state=open]:animate-none **:data-[slot=navigation-menu-link]:focus:ring-0 **:data-[slot=navigation-menu-link]:focus:outline-none",+ className+ )}+ {...props}+ />+);++const NavigationMenuLink = ({+ className,+ ...props+}: React.ComponentProps<typeof NavigationMenuPrimitive.Link>) => (+ <NavigationMenuPrimitive.Link+ data-slot="navigation-menu-link"+ className={cn(+ "flex flex-col gap-1 rounded-sm p-2 text-sm transition-all outline-none hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 data-[active=true]:bg-accent/50 data-[active=true]:text-accent-foreground data-[active=true]:hover:bg-accent data-[active=true]:focus:bg-accent [&_svg:not([class*='size-'])]:size-4",+ className+ )}+ {...props}+ />+);++const NavigationMenuIndicator = ({+ className,+ ...props+}: React.ComponentProps<typeof NavigationMenuPrimitive.Indicator>) => (+ <NavigationMenuPrimitive.Indicator+ data-slot="navigation-menu-indicator"+ className={cn(+ "top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:animate-in data-[state=visible]:fade-in",+ className+ )}+ {...props}+ >+ <div className="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" />+ </NavigationMenuPrimitive.Indicator>+);++export {+ NavigationMenu,+ NavigationMenuList,+ NavigationMenuItem,+ NavigationMenuContent,+ NavigationMenuTrigger,+ NavigationMenuLink,+ NavigationMenuIndicator,+ NavigationMenuViewport,+ navigationMenuTriggerStyle,+};diff --git a/constants/links.ts b/constants/links.tsindex c9416df..03c26ad 100644--- a/constants/links.ts+++ b/constants/links.ts@@ -1,7 +1,7 @@export const GITHUB = {branch: "main",org: "shadcn-labs",- repo: "shadcn-registry-starter",+ repo: "pdfcn",user: "Aniket-508",} as const;diff --git a/constants/nav.ts b/constants/nav.tsnew file mode 100644index 0000000..8b89347--- /dev/null+++ b/constants/nav.ts@@ -0,0 +1,56 @@+import { ROUTES } from "./routes";++export interface LabsNavLink {+ href: string;+ name: string;+ description?: string;+}++export const LABS_REGISTRIES = [+ { href: "https://termcn.dev", name: "termcn" },+ { href: "https://emailcn.run", name: "emailcn" },+ { href: "https://framecn.dev", name: "framecn" },+ { href: "https://ogimagecn.com", name: "ogimagecn" },+ { href: "https://agentcn.run", name: "agentcn" },+ { href: "https://mcpcn.dev", name: "mcpcn" },+] as const satisfies readonly LabsNavLink[];++export const LABS_TEMPLATES = [+ { href: "https://startercn.vercel.app", name: "startercn" },+] as const satisfies readonly LabsNavLink[];++export const LABS_PORTS = [+ { href: "https://shadcn-cssinjs.com", name: "shadcn-cssinjs" },+] as const satisfies readonly LabsNavLink[];++export const LABS_SKILLS = [+ {+ href: "https://skills.sh/shadcn-labs/skills/launch-shadcn-registry",+ name: "launch-shadcn-registry",+ },+ {+ href: "https://skills.sh/shadcn-labs/skills/tailwind-to-stylex",+ name: "tailwind-to-stylex",+ },+ {+ href: "https://skills.sh/shadcn-labs/skills/mastra-file-agents",+ name: "mastra-file-agents",+ },+] as const satisfies readonly LabsNavLink[];++export const LABS_NAV_SECTIONS = [+ { id: "registries", items: LABS_REGISTRIES, title: "Registries" },+ { id: "templates", items: LABS_TEMPLATES, title: "Templates" },+ { id: "ports", items: LABS_PORTS, title: "Ports" },+ { id: "skills", items: LABS_SKILLS, title: "Skills" },+] as const;++export const TOP_LEVEL_SECTIONS = [+ { href: ROUTES.DOCS, name: "Introduction" },+ { href: ROUTES.DOCS_INSTALLATION, name: "Installation" },+ { href: ROUTES.DOCS_COMPONENTS, name: "Components" },+ { href: ROUTES.DOCS_BLOCKS, name: "Blocks" },+ { href: ROUTES.DOCS_MCP, name: "MCP" },+ { href: ROUTES.DOCS_REGISTRY, name: "Registry" },+ { href: ROUTES.LLMS, name: "llms.txt" },+];diff --git a/constants/routes.ts b/constants/routes.tsindex e776972..89eb3aa 100644--- a/constants/routes.ts+++ b/constants/routes.ts@@ -4,8 +4,11 @@ export const ROUTES = {API_CATALOG: "/.well-known/api-catalog",API_STATUS: "/api/status",DOCS: "/docs",+ DOCS_BLOCKS: "/docs/blocks",DOCS_COMPONENTS: "/docs/components",DOCS_INSTALLATION: "/docs/installation",+ DOCS_MCP: "/docs/mcp",+ DOCS_REGISTRY: "/docs/registry",HOME: "/",LLMS: "/llms.txt",LLMS_FULL: "/llms-full.txt",diff --git a/content/docs/(root)/mcp.mdx b/content/docs/(root)/mcp.mdxnew file mode 100644index 0000000..443e56b--- /dev/null+++ b/content/docs/(root)/mcp.mdx@@ -0,0 +1,28 @@+---+title: MCP+description: Learn how to use the shadcn MCP (Model Context Protocol) server with pdfcn.+---++[MCP](https://modelcontextprotocol.io/) is an open protocol that standardizes how applications provide context to LLMs. The shadcn CLI can register an MCP server so your editor can discover registry components—including items you install from **pdfcn** via the same CLI.++## Configure MCP++Run:++```bash+npx shadcn@latest mcp init+```++Choose your MCP client when prompted, then enable the MCP server in that client to finish setup.++## Usage++With MCP enabled, you can ask your IDE to work with **Takumi PDF** and **Forme PDF** patterns and pdfcn registry components. Example prompts:++- Build an invoice layout with **Table**, **Heading**, **Text**, and **KeyValue**.+- Add a **QRCode** and **Signature** to a PDF document.+- Create a report with **Graph**, **DataTable**, and **PageHeader**.+- Lay out a PDF using **Section**, **Stack**, **Divider**, and **KeepTogether**.+- Implement a multi-page flow with **PageBreak**, **PageNumber**, and **PageFooter**.++Install components from this registry with `npx shadcn@latest add` and the JSON URL from each docs page. Components work with sensible defaults.diff --git a/content/docs/(root)/meta.json b/content/docs/(root)/meta.jsonindex 8da4046..aa6f9aa 100644--- a/content/docs/(root)/meta.json+++ b/content/docs/(root)/meta.json@@ -1,4 +1,4 @@{- "title": "Get Started",- "pages": ["index", "bases"]+ "pages": ["index", "installation", "mcp", "registry", "bases"],+ "title": "Overview"}diff --git a/content/docs/(root)/registry.mdx b/content/docs/(root)/registry.mdxnew file mode 100644index 0000000..113df32--- /dev/null+++ b/content/docs/(root)/registry.mdx@@ -0,0 +1,71 @@+---+title: Registry+description: Learn how to use the pdfcn registry with the shadcn CLI.+---++The **pdfcn** registry ships Takumi PDF and Forme PDF components, blocks, and themes in the [shadcn registry format](https://ui.shadcn.com/docs/registry). Register the namespace once in `components.json`, then pull items by name with the CLI.++## Setup++Add a **registries** entry for this site. See the [shadcn registry documentation](https://ui.shadcn.com/docs/registry) for all `components.json` fields and behaviors.++```json+{+ "registries": {+ "@pdfcn": "https://pdfcn.dev/r/{name}.json"+ }+}+```++You can replace `@pdfcn` with another namespace; it only needs to match what you pass to `shadcn add`.++## Usage++Items are namespaced by base: `takumi/` for Takumi PDF and `forme/` for Forme PDF.++Registry files follow these destinations:++- Components install into `components/ui/`.+- Blocks install into the configured blocks directory.++Components declare their dependencies, so installing a component does not require additional setup.++### Takumi PDF++Install a component:++```bash+npx shadcn@latest add @pdfcn/takumi/text+```++Install a block:++```bash+npx shadcn@latest add @pdfcn/takumi/invoice-minimal+```++Without a registry alias, use the full URL (as on each docs page):++```bash+npx shadcn@latest add https://pdfcn.dev/r/takumi/text.json+```++### Forme PDF++Install a component:++```bash+npx shadcn@latest add @pdfcn/forme/text+```++Install a block:++```bash+npx shadcn@latest add @pdfcn/forme/invoice-minimal+```++Without a registry alias, use the full URL (as on each docs page):++```bash+npx shadcn@latest add https://pdfcn.dev/r/forme/text.json+```diff --git a/content/docs/blocks/meta.json b/content/docs/blocks/meta.jsonindex f9fcefa..1e17e78 100644--- a/content/docs/blocks/meta.json+++ b/content/docs/blocks/meta.json@@ -1,16 +1,4 @@{"title": "Blocks",- "pages": [- "index",- "invoice-classic",- "invoice-consultant",- "invoice-corporate",- "invoice-creative",- "invoice-minimal",- "invoice-modern",- "report-financial",- "report-marketing",- "report-operations",- "report-security"- ]+ "pages": ["index", "takumi", "forme"]}diff --git a/content/docs/components/meta.json b/content/docs/components/meta.jsonindex 24b049a..233be71 100644--- a/content/docs/components/meta.json+++ b/content/docs/components/meta.json@@ -1,30 +1,4 @@{"title": "Components",- "pages": [- "index",- "alert",- "badge",- "card",- "data-table",- "divider",- "form",- "graph",- "heading",- "keep-together",- "key-value",- "link",- "list",- "page-break",- "page-footer",- "page-header",- "page-number",- "pdf-image",- "qrcode",- "section",- "signature",- "stack",- "table",- "text",- "watermark"- ]+ "pages": ["index", "takumi", "forme"]}diff --git a/hooks/use-icon-animation.ts b/hooks/use-icon-animation.tsnew file mode 100644index 0000000..ca2b501--- /dev/null+++ b/hooks/use-icon-animation.ts@@ -0,0 +1,22 @@+import { useCallback, useRef } from "react";++export interface AnimatedIconHandle {+ startAnimation: () => void;+ stopAnimation: () => void;+}++export const useIconAnimation = <+ T extends AnimatedIconHandle = AnimatedIconHandle,+>() => {+ const iconRef = useRef<T>(null);++ const onMouseEnter = useCallback(() => {+ iconRef.current?.startAnimation();+ }, []);++ const onMouseLeave = useCallback(() => {+ iconRef.current?.stopAnimation();+ }, []);++ return { iconRef, onMouseEnter, onMouseLeave };+};diff --git a/lib/docs.ts b/lib/docs.tsindex 39992c5..a78cb4c 100644--- a/lib/docs.ts+++ b/lib/docs.ts@@ -9,6 +9,26 @@ export const EXCLUDED_SECTIONS = new Set(["installation", "(root)"]);export const isComponentsFolder = (folder: PageTreeFolder) =>folder.$id === "components" || folder.name === "Components";+export const isBlocksFolder = (folder: PageTreeFolder) =>+ folder.$id === "blocks" || folder.name === "Blocks";++export type DocsSidebarPanel = "components" | "blocks";++const isPathWithin = (pathname: string, route: string) =>+ pathname === route || pathname.startsWith(`${route}/`);++export const getDocsSidebarPanel = (+ pathname: string+): DocsSidebarPanel | null => {+ if (isPathWithin(pathname, ROUTES.DOCS_COMPONENTS)) {+ return "components";+ }+ if (isPathWithin(pathname, ROUTES.DOCS_BLOCKS)) {+ return "blocks";+ }+ return null;+};+const TITLE_OVERRIDES: Record<string, string> = {json: "JSON","qr-code": "QR Code",diff --git a/lib/page-tree.ts b/lib/page-tree.tsindex 3db73cf..dae768c 100644--- a/lib/page-tree.ts+++ b/lib/page-tree.ts@@ -1,12 +1,22 @@-import type { Node as PageTreeNode } from "fumadocs-core/page-tree";+import type {+ Node as PageTreeNode,+ Root as PageTreeRoot,+} from "fumadocs-core/page-tree";++import {+ EXCLUDED_SECTIONS,+ isBlocksFolder,+ isComponentsFolder,+} from "@/lib/docs";+import { DEFAULT_BASE } from "@/registry/bases";export type PageTreeFolder = Extract<PageTreeNode, { type: "folder" }>;export type PageTreePage = Extract<PageTreeNode, { type: "page" }>;-export const getPagesFromFolder = (folder: PageTreeFolder): PageTreePage[] =>- folder.children.filter(- (child): child is PageTreePage => child.type === "page"- );+export interface TreeGroup {+ label: string;+ pages: PageTreePage[];+}export const getAllPagesFromFolder = (folder: PageTreeFolder@@ -23,3 +33,131 @@ export const getAllPagesFromFolder = (return pages;};++export const getPagesFromFolder = (folder: PageTreeFolder): PageTreePage[] =>+ folder.children.filter(+ (child): child is PageTreePage => child.type === "page"+ );++const matchesBase = (folder: PageTreeFolder, base: string): boolean =>+ folder.$id === base ||+ (typeof folder.name === "string" && folder.name.toLowerCase() === base);++export const findBaseFolder = (+ folder: PageTreeFolder,+ base: string+): PageTreeFolder | undefined => {+ for (const child of folder.children) {+ if (child.type !== "folder") {+ continue;+ }+ if (matchesBase(child, base)) {+ return child;+ }+ }+};++export const getCategoryFolders = (+ folder: PageTreeFolder,+ base: string+): PageTreeFolder[] => {+ const baseFolder = findBaseFolder(folder, base);+ if (!baseFolder) {+ return [];+ }++ return baseFolder.children.filter(+ (c): c is PageTreeFolder => c.type === "folder"+ );+};++export const getFolderPages = (+ folder: PageTreeFolder,+ base?: string+): PageTreePage[] => {+ if (base) {+ const baseFolder = findBaseFolder(folder, base);+ if (!baseFolder) {+ return [];+ }++ return getAllPagesFromFolder(baseFolder);+ }++ return getAllPagesFromFolder(folder);+};++export const getCurrentBase = (pathname: string): string => {+ const baseScopedMatch = pathname.match(+ /\/docs\/(?:components|blocks)\/([^/]+)(?:\/|$)/+ );+ if (baseScopedMatch) {+ return baseScopedMatch[1];+ }++ return DEFAULT_BASE;+};++export const getTreeGroups = (+ tree: PageTreeRoot,+ currentBase: string+): TreeGroup[] => {+ const groups: TreeGroup[] = [];++ for (const item of tree.children) {+ if (item.type !== "folder") {+ continue;+ }+ if (EXCLUDED_SECTIONS.has(item.$id ?? "")) {+ continue;+ }++ if (isComponentsFolder(item)) {+ // Check if there are base folders (takumi, forme)+ const baseFolder = findBaseFolder(item, currentBase);+ if (baseFolder) {+ // Get pages from the base folder+ const pages = getAllPagesFromFolder(baseFolder).filter(+ (page) => !page.url.endsWith("/components") && !page.url.endsWith("/components/")+ );+ if (pages.length > 0) {+ groups.push({+ label: "Components",+ pages,+ });+ }+ } else {+ // No base folder found, get all pages from components folder+ const pages = getAllPagesFromFolder(item).filter(+ (page) => !page.url.endsWith("/components") && !page.url.endsWith("/components/")+ );+ if (pages.length > 0) {+ groups.push({+ label: "Components",+ pages,+ });+ }+ }+ } else if (isBlocksFolder(item)) {+ const pages = getFolderPages(item, currentBase).filter(+ (page) => !page.url.endsWith("/blocks") && !page.url.endsWith("/blocks/")+ );+ if (pages.length > 0) {+ groups.push({+ label: typeof item.name === "string" ? item.name : String(item.name),+ pages,+ });+ }+ } else {+ const pages = getFolderPages(item);+ if (pages.length > 0) {+ groups.push({+ label: typeof item.name === "string" ? item.name : String(item.name),+ pages,+ });+ }+ }+ }++ return groups;+};