'use client'; import React from 'react' import { Link, usePathname, useRouter } from "@/components/navigation"; import { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "@/components/ui/breadcrumb" import { Icon } from "@/components/ui/icon" import { ReactNode } from "react"; const SiteBreadcrumb = ({ children }: { children?: ReactNode }) => { const location = usePathname(); const locations = location.split('/').filter(path => path) return (
{ locations.map((link, index) => { let href = `/${locations.slice(0, index + 1).join('/')}` let itemLink = link const isLast = index === locations.length - 1; return ( {isLast ? ( itemLink?.replaceAll("-", " ") ) : ( {itemLink?.replaceAll("-", "")} )} {locations.length !== index + 1 && } ) }) }
{children}
); }; export default SiteBreadcrumb;