feat(blog): add dynamic blog post rendering with i18n support and error handling in [slug].vue

This commit is contained in:
2026-04-22 00:20:52 +02:00
parent e66c7984a4
commit 127db8b77a
2 changed files with 7 additions and 9 deletions
@@ -2,14 +2,14 @@
const { locale } = useI18n()
const route = useRoute()
const slug = Array.isArray(route.params.slug) ? route.params.slug.join('/') : route.params.slug
const slug = route.params.slug as string
const isFr = locale.value === 'fr'
const collection = isFr ? 'blog_fr' : 'blog_en'
// blog_fr prefix = /fr/blog, blog_en prefix = /en/blog (aligned with content.config.ts)
const path = isFr ? `/fr/blog/${slug}` : `/en/blog/${slug}`
const { data: page } = await useAsyncData(`blog-${locale.value}-${slug}`, () =>
queryCollection(collection).path(path).first()
isFr
? queryCollection('blog_fr').path(path).first()
: queryCollection('blog_en').path(path).first()
)
if (!page.value) {