import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "@suphark/ui/components/ui/breadcrumb"; import { cn } from "@suphark/ui/lib/utils"; import Link from "next/link"; import * as React from "react"; /** * Represents a single item in the breadcrumb trail. */ export type PageBreadcrumbItem = { /** * The text to display for the breadcrumb item. */ label: string; /** * The URL to link to. If not provided, this item will be rendered * as the current, non-clickable page (``). */ href?: string; /** * An optional icon element to display before the label. */ icon?: React.ReactNode; }; /** * Props for the PageBreadcrumb component. */ type PageBreadcrumbProps = { /** * An array of breadcrumb items to display. */ items: PageBreadcrumbItem[]; /** * Optional CSS class(es) to apply to the root component. */ className?: string; }; /** * A shared component that renders a breadcrumb trail based on a list of items. * It automatically handles rendering items as links or as the current page. * * @example * const items = [ * { label: "Home", href: "/" }, * { label: "Projects", href: "/projects" }, * { label: "My Project", icon: }, * ]; * */ export function PageBreadcrumb({ items, className }: PageBreadcrumbProps) { return ( {items.map((item, index) => ( // biome-ignore lint/suspicious/noArrayIndexKey: ลำดับ breadcrumb คงที่ ไม่ reorder — label อาจซ้ำจึงใช้ตำแหน่งร่วม {item.href ? ( // Item is a clickable link } > {item.icon} {item.label} ) : ( // Item is the current, non-clickable page {item.icon} {item.label} )} {/* Add a separator if it's not the last item */} {index < items.length - 1 && } ))} ); } // export default PageBreadcrumb;