Replies: 1 comment
-
|
Nuxt Content v3 does not really have a If only the blog is available in const post = await queryCollection("blog")
.path(`/blog/${slug}`)
.first()and do not include the active UI locale in that query. If you do have localized content later, a common pattern is to store the locale in the path or metadata: content/blog/en-US/my-post.md
content/blog/fr-FR/my-post.mdThen query the active locale first and fallback to const locale = route.params.locale ?? "en-US"
const post =
await queryCollection("blog").path(`/blog/${locale}/${slug}`).first()
?? await queryCollection("blog").path(`/blog/en-US/${slug}`).first()So short version: yes, handle the fallback in your route/query layer. Nuxt Content provides the collection/query primitives, but it does not decide locale fallback policy for you. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I found that there is not
defaultLocaleor any i18n config on nuxt/content v3 nuxt.config.ts. How could I setup nuxt/content v3 multi language or I should handle by myself in queryCollection?My website has multi-language but blog system under this site only has
en-US, I want to fallback other language to en-US in blog pages when user switch any other language.Beta Was this translation helpful? Give feedback.
All reactions