This commit is contained in:
Bobbie Goede 2024-09-21 16:21:33 +03:00 committed by GitHub
commit 2fe984005e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 8 deletions

View File

@ -64,18 +64,15 @@ export async function resolvePagesRoutes (): Promise<NuxtPage[]> {
shouldUseServerComponents: !!nuxt.options.experimental.componentIslands,
})
const pages = uniqueBy(allRoutes, 'path')
const shouldAugment = nuxt.options.experimental.scanPageMeta || nuxt.options.experimental.typedPages
const pages = uniqueBy(allRoutes, 'path')
await nuxt.callHook('pages:extend', pages)
if (shouldAugment) {
const augmentedPages = await augmentPages(pages, nuxt.vfs)
await nuxt.callHook('pages:extend', pages)
await augmentPages(pages, nuxt.vfs, augmentedPages)
augmentedPages.clear()
} else {
await nuxt.callHook('pages:extend', pages)
await augmentPages(pages, nuxt.vfs)
}
await nuxt.callHook('pages:resolved', pages)
return pages
}

View File

@ -189,6 +189,13 @@ export interface NuxtHooks {
*/
'pages:extend': (pages: NuxtPage[]) => HookResult
/**
* Called after pages routes are resolved.
* @param pages Array containing resolved pages
* @returns Promise
*/
'pages:resolved': (pages: NuxtPage[]) => HookResult
/**
* Called when resolving `app/router.options` files. It allows modifying the detected router options files
* and adding new ones.