📄 Huge intl feature
Some checks failed
Build and Deploy Next.js Blog to Staging / 🔍 Code Quality Checks (push) Failing after 15s
Build and Deploy Next.js Blog to Staging / 🏗️ Build and Push Docker Image (push) Has been skipped
Build and Deploy Next.js Blog to Staging / 🚀 Deploy to Staging (push) Has been skipped

This commit was merged in pull request #10.
This commit is contained in:
RJ
2025-12-03 00:17:34 +02:00
committed by Rares J
parent 072320ed73
commit 91afe03109
48 changed files with 955 additions and 138 deletions

View File

@@ -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>