import React from "react"; import { Link, useLocation } from "react-router-dom"; import { cn } from "@/lib/utils"; import { ChevronRight, Home } from "lucide-react"; export interface BreadcrumbsProps { className?: string; items?: Array<{ label: string; href?: string }>; } export function Breadcrumbs({ className, items }: BreadcrumbsProps) { const location = useLocation(); // Auto-generate breadcrumbs from URL if not provided const generatedItems = React.useMemo(() => { if (items) return items; const pathParts = location.pathname.split("/").filter(Boolean); const breadcrumbs: Array<{ label: string; href?: string }> = [ { label: "Home", href: "/" }, ]; let currentPath = ""; pathParts.forEach((part, index) => { currentPath += `/${part}`; const label = part .split("-") .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) .join(" "); breadcrumbs.push({ label, href: index < pathParts.length - 1 ? currentPath : undefined, }); }); return breadcrumbs; }, [items, location.pathname]); return ( ); }