'use client'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { Fragment } from 'react'; import { BreadcrumbsSchema } from './breadcrumbs-schema'; interface BreadcrumbItem { label: string; href: string; current?: boolean; } function HomeIcon({ className }: { className?: string }) { return ( ); } function ChevronIcon({ className }: { className?: string }) { return ( ); } function formatSegmentLabel(segment: string): string { const specialCases: { [key: string]: string } = { blog: 'Blog', tags: 'Tag-uri', about: 'Despre', }; if (specialCases[segment]) { return specialCases[segment]; } return segment .split('-') .map(word => word.charAt(0).toUpperCase() + word.slice(1)) .join(' '); } export function Breadcrumbs({ items }: { items?: BreadcrumbItem[] }) { const pathname = usePathname(); let breadcrumbs: BreadcrumbItem[] = items || []; if (!items) { const segments = pathname.split('/').filter(Boolean); breadcrumbs = segments.map((segment, index) => { const href = '/' + segments.slice(0, index + 1).join('/'); const label = formatSegmentLabel(segment); const current = index === segments.length - 1; return { label, href, current }; }); } if (pathname === '/') { return null; } const schemaItems = [ { position: 1, name: 'Acasă', item: '/' }, ...breadcrumbs.map((item, index) => ({ position: index + 2, name: item.label, item: item.href, })), ]; return ( <> ); }