you just create a page named about.vue
right there
Do you want only a subset of your pages generated when you run nuxt generate
?
I was wanting to do the same thing today. My solution was to use a custom module to leverage the internal plugin system (Note that in the latest releases these are now called hooks and have been re-worked a bit. They don't appear to be documented yet.)
I'm not sure if this is the best approach but it certainly seems to do the trick for now.
modules/custom-generate.js
module.exports = function () {
this.nuxt.hook('generate:extendRoutes', async routes => {
const whiteList = ['/about', '/login'];
const routesToGenerate = routes.filter(page => whiteList.includes(page.route));
routes.splice(0, routes.length, ...routesToGenerate);
});
};
nuxt.config.js
modules: [
'~modules/custom-generate.js'
],
@qm3ster Good point. I think the only catch is that generate.routes
only gives you control over dynamic routes. If you want to blacklist some static routes from generate, you still need the extendRoutes
hook, or is there a better way?
I tried but it did not work
generate: {
routes: ["about"]
},
How to setting generate.routes
make nuxt
disables route autogeneration ? Can you show the code?
Nuxt Version : 1.3.0
@dan-peterson @SzHeJason I was wrong, this has been changed a gorillion months ago.
The generate.routes
are now merged with autodetected routes.
generate:extendRoutes
seems like the only way now.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For all googlers, this is possible via regex in generate.exclude
. if the route URL matches the regex, the page will be excluded from generating but can still be served as "SPA route".
Most helpful comment
Do you want only a subset of your pages generated when you run
nuxt generate
?I was wanting to do the same thing today. My solution was to use a custom module to leverage the internal plugin system (Note that in the latest releases these are now called hooks and have been re-worked a bit. They don't appear to be documented yet.)
I'm not sure if this is the best approach but it certainly seems to do the trick for now.
modules/custom-generate.js
nuxt.config.js