A way to disable auto route generation ?
maxerbox opened this issue · 4 comments
I'm looking for a replacement for nuxtent, which is deprecated.
I was wondering if we could prevent auto generating routes based on the markdown file names ?
Thanks for getting in touch! I think I will add a generateRoutes
option in the next release.
For now, there is a way but it feels hacky. Routes are generated like so:
routes.push(...collections[collection.name].files.map(({ data }) => data.path))
As you can see, the route for each file is actually stored in the front matter (data
), which you can modify in serverTransform
like so:
serverTransform (collection) {
collection.forEach(({ data }) => {
data.path = '/' // Some route which you do want to generate
})
return collection
}
If you've got any other suggestions of how Nuxt Markdown could replace Nuxtent, I'd really appreciate if you create another issue. Or if you want to help make Nuxt Markdown, I would love to get some other collaborators on board!
Thanks, for some reason, the generate.exclude
option in nuxt.config.js
did not skip them. This worked for me.
I will make sure to honour the generate.exclude
option in the next release; I'll look for a better way to generate routes than I am at the moment.
To give you some context, I'm using one subfolder under ~/content
for links, so I don't want to create routes for them.