Nuxt Content vs i18n!
Hola amigos! 🙂
I am on the nuxt content3 and I want to pull a document from dir content/es at the url '/es/docs' when I change locale to 'es'. url for 'en' is simply '/docs', but how do i pull the right document for the locale?
config:
docs: defineCollection({
type: 'page',
source: '1.docs/**/*',
schema: z.object({
title: z.string().nonempty(),
description: z.string().nonempty()
})
})
slug page:
const { data: page } = await useAsyncData(route.path, async () => {
let content = await queryCollection('docs')
.where('path', 'LIKE', route.path)
.first()
if (!content) {
console.warn(
`No content found for ${route.path}, falling back to navigation.`
)
content = await queryCollection('docs').path(route.path).first()
}
return content
})