Files
RJ 6adb3a6979
All checks were successful
PR Checks / lint-and-build (pull_request) Successful in 21s
Build and Deploy Next.js Blog to Production / 🔍 Code Quality Checks (push) Successful in 16s
Build and Deploy Next.js Blog to Production / 🏗️ Build and Push Docker Image (push) Successful in 1m4s
Build and Deploy Next.js Blog to Production / 🚀 Deploy to Production (push) Successful in 55s
📝 update breadcrumbs , nav for mobile and homepage translations
2025-12-05 16:25:56 +02:00

47 lines
1.1 KiB
TypeScript

import { Breadcrumbs } from '@/components/layout/Breadcrumbs'
import { getPostBySlug } from '@/lib/markdown'
import { getTranslations } from 'next-intl/server'
interface BreadcrumbItem {
label: string
href: string
current?: boolean
}
export default async function BlogPostBreadcrumb({
params,
}: {
params: Promise<{ slug: string[] }>
}) {
const t = await getTranslations('Breadcrumbs')
const { slug } = await params
const slugPath = slug.join('/')
const post = await getPostBySlug(slugPath)
const items: BreadcrumbItem[] = [
{
label: t('blog'),
href: '/blog',
},
]
if (slug.length > 1) {
for (let i = 0; i < slug.length - 1; i++) {
const segmentPath = slug.slice(0, i + 1).join('/')
const dirName = slug[i]
items.push({
label: t(dirName) || dirName.charAt(0).toUpperCase() + dirName.slice(1),
href: `/blog/${segmentPath}`,
})
}
}
items.push({
label: post ? post.frontmatter.title : slug[slug.length - 1],
href: `/blog/${slugPath}`,
current: true,
})
return <Breadcrumbs items={items} />
}