fix(nuxt): include build-time pages in prerender routes (#27569)

This commit is contained in:
Daniel Roe 2024-06-13 23:35:57 +01:00 committed by GitHub
parent ffdc358561
commit 8af56b1761
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -275,6 +275,20 @@ 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) {
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)
}
}
}
})
}
nuxt.hook('imports:extend', (imports) => {
imports.push(
{ name: 'definePageMeta', as: 'definePageMeta', from: resolve(runtimeDir, 'composables') },