fix(nuxt): add / even if pages module isn't enabled

This commit is contained in:
Daniel Roe 2024-06-16 00:19:00 +01:00
parent cb77ddc308
commit dabcb5ecc9
No known key found for this signature in database
GPG Key ID: CBC814C393D93268
2 changed files with 5 additions and 11 deletions

View File

@ -498,7 +498,11 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
for (const route of ['/200.html', '/404.html']) {
routes.add(route)
}
if (!nuxt.options.ssr) {
if (nuxt.options.ssr) {
if (nitro.options.prerender.crawlLinks) {
routes.add('/')
}
} else {
routes.add('/index.html')
}
})

View File

@ -275,16 +275,6 @@ 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.options.ssr) {
nuxt.hook('app:templatesGenerated', () => {
const nitro = useNitro()
if (nitro.options.prerender.crawlLinks) {
nitro.options.prerender.routes.push('/')
}
})
}
nuxt.hook('imports:extend', (imports) => {
imports.push(
{ name: 'definePageMeta', as: 'definePageMeta', from: resolve(runtimeDir, 'composables') },