Mr XQ
Mr XQ
NNuxt
Created by Mr XQ on 8/7/2024 in #❓・help
Nuxt-Content and Nuxt I18n: How to create a localized content
I am working on a Nuxt.js project that uses @nuxt/content and @nuxtjs/i18n modules to create a localized blog. If I use content/blog/hellow-world.md the page works fine and the content gets fetched just fine, but if I tried to localize the content folder by creating separate language folders like this: content/en/blog/hellow-world.md and changing the fetching method inside blog/index file to include the locale like this: const i18n = useI18n() const {data: posts} = await useAsyncData('get-all-posts', () => { return queryContent(i18n.locale.value + '/blog').sort({date: -1}).find() }) then the blog posts are not shown, and I get 404 (Document not found!) This is the repo link: https://github.com/abdurrahmanseyidoglu/personal-website-nuxt and this is the question on stackoverflow (I tried to post all the details here, but unfortunately, there is a character limit) : https://stackoverflow.com/questions/78843859/nuxt-js-content-and-nuxt-i18n-how-to-create-a-localized-content
1 replies
NNuxt
Created by Mr XQ on 12/13/2022 in #❓・help
Best practice to store API end points
In nuxt2 I used Axios and store my end points under
services/api.js
services/api.js
example : api.js:
export default ($apiClient) => ({
fetchBlog() {
return $apiClient.$get("/blog");
},

latestPosts(test) {
return $apiClient.$get("test");
},
export default ($apiClient) => ({
fetchBlog() {
return $apiClient.$get("/blog");
},

latestPosts(test) {
return $apiClient.$get("test");
},
and I use it inside pages like this: index.js:
const blog= await this.$api.fetchBlog()
const blog= await this.$api.fetchBlog()
What's the best way to store and use API endpoints in nuxt3? thank you.
5 replies