mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): add pages in correct hook when generating (#22088)
This commit is contained in:
parent
dcef9d94cd
commit
e9dac76348
@ -205,22 +205,20 @@ export default defineNuxtModule({
|
|||||||
if (nuxt.options.dev || !nitro.options.static) { return }
|
if (nuxt.options.dev || !nitro.options.static) { return }
|
||||||
// Prerender all non-dynamic page routes when generating app
|
// Prerender all non-dynamic page routes when generating app
|
||||||
const prerenderRoutes = new Set<string>()
|
const prerenderRoutes = new Set<string>()
|
||||||
nuxt.hook('modules:done', () => {
|
nuxt.hook('pages:extend', (pages) => {
|
||||||
nuxt.hook('pages:extend', (pages) => {
|
prerenderRoutes.clear()
|
||||||
prerenderRoutes.clear()
|
const processPages = (pages: NuxtPage[], currentPath = '/') => {
|
||||||
const processPages = (pages: NuxtPage[], currentPath = '/') => {
|
for (const page of pages) {
|
||||||
for (const page of pages) {
|
// Add root of optional dynamic paths and catchalls
|
||||||
// Add root of optional dynamic paths and catchalls
|
if (OPTIONAL_PARAM_RE.test(page.path) && !page.children?.length) { prerenderRoutes.add(currentPath) }
|
||||||
if (OPTIONAL_PARAM_RE.test(page.path) && !page.children?.length) { prerenderRoutes.add(currentPath) }
|
// Skip dynamic paths
|
||||||
// Skip dynamic paths
|
if (page.path.includes(':')) { continue }
|
||||||
if (page.path.includes(':')) { continue }
|
const route = joinURL(currentPath, page.path)
|
||||||
const route = joinURL(currentPath, page.path)
|
prerenderRoutes.add(route)
|
||||||
prerenderRoutes.add(route)
|
if (page.children) { processPages(page.children, route) }
|
||||||
if (page.children) { processPages(page.children, route) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
processPages(pages)
|
}
|
||||||
})
|
processPages(pages)
|
||||||
})
|
})
|
||||||
nuxt.hook('nitro:build:before', (nitro) => {
|
nuxt.hook('nitro:build:before', (nitro) => {
|
||||||
for (const route of nitro.options.prerender.routes || []) {
|
for (const route of nitro.options.prerender.routes || []) {
|
||||||
|
Loading…
Reference in New Issue
Block a user