import { Fragment } from 'react'; import { Link } from '@@/Link'; import './Breadcrumbs.css'; export interface Crumb { label: string; link?: string; linkParams?: Record; } interface Props { breadcrumbs: (Crumb | string)[]; } export function Breadcrumbs({ breadcrumbs }: Props) { return (
{breadcrumbs.map((crumb, index) => ( {renderCrumb(crumb)} {index !== breadcrumbs.length - 1 ? ' > ' : ''} ))}
); } function renderCrumb(crumb: Crumb | string) { if (typeof crumb === 'string') { return crumb; } if (crumb.link) { return ( {crumb.label} ); } return crumb.label; }