"use client";
import * as React from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { ChevronRight, ExternalLink, Menu, X } from "lucide-react";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import { DOCS_NAV, type DocsNavLink } from "./nav-config";
function NavLinks({ onNavigate, className }: { onNavigate?: () => void; className?: string }) {
const pathname = usePathname();
return (
);
}
function NavItem({ link, active, onNavigate }: { link: DocsNavLink; active: boolean; onNavigate?: () => void }) {
return (
{link.title}
{link.badge ? {link.badge} : null}
{link.external ? : null}
);
}
/** Desktop sidebar: sticky under the marketing header. */
export function DocsSidebar({ className }: { className?: string }) {
return (
);
}
/** Mobile: compact bar with the current page and a drawer with the full navigation. */
export function DocsMobileNav() {
const [open, setOpen] = React.useState(false);
const pathname = usePathname();
const current = React.useMemo(() => DOCS_NAV.flatMap((s) => s.links.map((l) => ({ ...l, section: s.title }))).find((l) => l.href === pathname), [pathname]);
React.useEffect(() => {
if (!open) return;
const onKey = (e: KeyboardEvent) => {
if (e.key === "Escape") setOpen(false);
};
document.addEventListener("keydown", onKey);
const prev = document.body.style.overflow;
document.body.style.overflow = "hidden";
return () => {
document.removeEventListener("keydown", onKey);
document.body.style.overflow = prev;
};
}, [open]);
return (
{current?.section ?? "Docs"}
{current?.title ?? "Documentation"}
{open ? (
) : null}
);
}