feat(05): i18n strategy prefix — /fr/blog and /en/blog explicit routes, update collection prefixes
This commit is contained in:
@@ -5,8 +5,8 @@ const route = useRoute()
|
||||
const slug = Array.isArray(route.params.slug) ? route.params.slug.join('/') : route.params.slug
|
||||
const isFr = locale.value === 'fr'
|
||||
const collection = isFr ? 'blog_fr' : 'blog_en'
|
||||
// blog_fr prefix = /blog, blog_en prefix = /en/blog (aligned with content.config.ts)
|
||||
const path = isFr ? `/blog/${slug}` : `/en/blog/${slug}`
|
||||
// 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()
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ export default defineContentConfig({
|
||||
collections: {
|
||||
blog_fr: defineCollection({
|
||||
type: 'page',
|
||||
source: { include: 'fr/blog/**/*.md', prefix: '/blog' },
|
||||
source: { include: 'fr/blog/**/*.md', prefix: '/fr/blog' },
|
||||
schema: blogSchema,
|
||||
}),
|
||||
blog_en: defineCollection({
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ export default defineNuxtConfig({
|
||||
name: "Killian' DAL-CIN - Developpeur Full Stack"
|
||||
},
|
||||
i18n: {
|
||||
strategy: 'prefix_except_default',
|
||||
strategy: 'prefix',
|
||||
defaultLocale: 'fr',
|
||||
baseUrl: 'https://killiandalcin.fr',
|
||||
locales: [
|
||||
|
||||
Reference in New Issue
Block a user