Reputation: 11
I have a static website where I'm also running a blog with the content from Contentful and everything inside the blog works fine. However, when generating the Nuxt routes, I have duplication with my posts URLs falling under /blog/post-title (which works fine and is the desired result), but also being generated with an error one level above as /post-title.
Any ideas on how to rewrite this? I've seen multiple versions of the code below.
generate: {
routes() {
return Promise.all([
client.getEntries({
content_type: "blogPost"
})
]).then(([posts]) => {
return [
...posts.items.map(posts => `blog/${posts.fields.slug}`),
];
});
}
},
Upvotes: 0
Views: 173
Reputation: 46696
Here, contentful is probably doing the generation by itself already. Telling Nuxt to exclude it's own routes could be a nice idea. We do have exactly this property hopefully: https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-generate/#exclude
You can pretty much ignore all of your routes and let Contentful manage by itself but you will probably need a middleground (and to adapt the regex).
But a naive and simple solution would be to do:
export default {
generate: {
exclude: [
/^\/pages/
]
}
}
Upvotes: 1