nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.06k stars 621 forks source link

Navigation content returns default language instead of specified language #2565

Closed jxk-developer closed 2 weeks ago

jxk-developer commented 6 months ago

Environment


Reproduction

Vue component file: [...slug].vue

Code snippet attempting to fetch French navigation content:

const { data: navigation } = await useAsyncData('nav', () =>
  fetchContentNavigation({ locale: 'fr' })
);

Expected Outcome: The navigation data should be in French. Actual Outcome: The navigation data is returned in the default language (English).

Link to reproduce: https://stackblitz.com/edit/nuxt-starter-aww5hu?file=pages%2F%5B...slug%5D.vue

Describe the bug

Configuration

When attempting to fetch navigation content in the French language from a Vue component, the expected result should be content returned in French (fr). However, the content is being returned in the default language (English) instead of the specified French language.

Additional context

It would be greatly appreciated if you could provide documentation on integrating @nuxt/i18n with @nuxt/content. This guidance would be invaluable for developers looking to leverage both modules effectively in their projects.

Logs

No response

deetz99 commented 6 months ago

Try this:

const { locale } = useI18n()

const { data: navigation } = await useAsyncData(
  'navigation',
  () => fetchContentNavigation(
    queryContent()
      .where({ _locale: locale.value })
  ), {
    watch: [locale]
  })
github-actions[bot] commented 1 month ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] commented 2 weeks ago

This issue was closed because it has been stalled for 30 days with no activity.