Hello, thanks for such a wonderful module. I have a question, is there any possibility to use i18n together with your module?
If you're using nuxt-i18n, you can save you files in different directories based on your supported languages and fetch them like this.
export default {
async asyncData({ app, params, $content }) {
const { slug } = params;
const posts = await $content("blog", app.i18n.locale, slug).fetch();
return { posts };
},
};
Content directory
content/
blog/
en/
article-1.md
article-2.md
es/
article-1.md
article-2.md
There is my code
async fetch() {
this.submenu = await this.$content('submenu', this.$i18n.locale, 'index').fetch().catch();
},
but when i switch page, content wouldn't update(
Also, have error in console UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
My structure:
content/
submenu/
ru/
index.md
uk/
index.md
@juliomrqz answer is the one I recommend, and also the one we use in the content documentation: https://github.com/nuxt/content/blob/master/docs/pages/_slug.vue#L31
@juliomrqz answer is the one I recommend, and also the one we use in the content documentation: https://github.com/nuxt/content/blob/master/docs/pages/_slug.vue#L31
But what if i want use this module not on page component. I have nav which i want place in .md file and get it in fetch function in my Header component.
Most helpful comment
If you're using nuxt-i18n, you can save you files in different directories based on your supported languages and fetch them like this.
Content directory