📄 Huge intl feature
Some checks failed
Some checks failed
This commit was merged in pull request #10.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
'use client'
|
||||
|
||||
import Link from 'next/link'
|
||||
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'
|
||||
|
||||
@@ -38,25 +39,33 @@ function ChevronIcon({ className }: { className?: string }) {
|
||||
)
|
||||
}
|
||||
|
||||
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()
|
||||
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 || []
|
||||
|
||||
@@ -71,12 +80,8 @@ export function Breadcrumbs({ items }: { items?: BreadcrumbItem[] }) {
|
||||
})
|
||||
}
|
||||
|
||||
if (pathname === '/') {
|
||||
return null
|
||||
}
|
||||
|
||||
const schemaItems = [
|
||||
{ position: 1, name: 'Acasă', item: '/' },
|
||||
{ position: 1, name: t('home'), item: '/' },
|
||||
...breadcrumbs.map((item, index) => ({
|
||||
position: index + 2,
|
||||
name: item.label,
|
||||
@@ -96,7 +101,7 @@ export function Breadcrumbs({ items }: { items?: BreadcrumbItem[] }) {
|
||||
<Link
|
||||
href="/"
|
||||
className="flex items-center text-gray-500 hover:text-primary-600 transition"
|
||||
aria-label="Acasă"
|
||||
aria-label={t('home')}
|
||||
>
|
||||
<HomeIcon className="w-4 h-4" />
|
||||
</Link>
|
||||
|
||||
Reference in New Issue
Block a user