'use client' import {Link} from '@/i18n/navigation' import { usePathname } from 'next/navigation' import { useLocale, useTranslations } from 'next-intl' 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 ( ) } export function Breadcrumbs({ items }: { items?: BreadcrumbItem[] }) { const pathname = usePathname() const locale = useLocale() const t = useTranslations('Breadcrumbs') // Hide breadcrumbs on main page const isMainPage = pathname === `/${locale}` || pathname === '/' if (isMainPage) { return null } const formatSegmentLabel = (segment: string): string => { const specialCases: { [key: string]: string } = { blog: t('blog'), tags: t('tags'), about: t('about'), } if (specialCases[segment]) { return specialCases[segment] } return segment .split('-') .map(word => word.charAt(0).toUpperCase() + word.slice(1)) .join(' ') } 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 } }) } const schemaItems = [ { position: 1, name: t('home'), item: '/' }, ...breadcrumbs.map((item, index) => ({ position: index + 2, name: item.label, item: item.href, })), ] return ( <> ) }