import { Link } from '@/components/Link/Link'; import React from 'react'; import { useLocation } from 'react-router-dom'; import * as styles from './Breadcrumb.styles'; import { ARIA_LABEL, DEFAULT_BASE, SEPARATOR_ICON } from './Breadcrumb.constants'; import { BreadcrumbPath, BreadcrumbProps } from './Breadcrumb.types'; const Breadcrumb: React.FC = ({ base = DEFAULT_BASE }) => { const location = useLocation(); const { pathname } = location; // Split the pathname and filter out empty strings const paths = pathname.split('/').filter(Boolean); // If on the home page, show only the base and return early if (paths.length === 0) { return ( ); } // Build breadcrumb links for all other paths const breadcrumbPaths: BreadcrumbPath[] = paths.map((path, index) => { const href = `/${paths.slice(0, index + 1).join('/')}`; const name = path.charAt(0).toUpperCase() + path.slice(1); return { name, href }; }); return ( ); }; export default Breadcrumb;