fix(nuxt): only inject root path in prerender

This commit is contained in:
Daniel Roe 2024-06-16 00:00:20 +01:00
parent a05b5343a4
commit 44cada95a6
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -276,15 +276,11 @@ export default defineNuxtModule({
})
// TODO: inject routes in `200.html` in next nitro upgrade (2.9.7+) via https://github.com/unjs/nitro/pull/2517
if (!nuxt.options.dev && !nuxt.options._prepare) {
if (!nuxt.options.dev && !nuxt.options._prepare && nuxt.options.ssr) {
nuxt.hook('app:templatesGenerated', (app) => {
const nitro = useNitro()
if (nitro.options.prerender.crawlLinks) {
for (const page of app.pages!) {
if (page.path && !page.path.includes(':')) {
nitro.options.prerender.routes.push(page.path)
}
}
nitro.options.prerender.routes.push('/')
}
})
}