mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat(nuxt): expose filtered templates in app:templatesGenerated
hook (#21935)
This commit is contained in:
parent
2f734df9b5
commit
c5f94be5d1
@ -33,8 +33,10 @@ export async function generateApp (nuxt: Nuxt, app: NuxtApp, options: { filter?:
|
||||
|
||||
// Compile templates into vfs
|
||||
const templateContext = { utils: templateUtils, nuxt, app }
|
||||
await Promise.all((app.templates as Array<ReturnType<typeof normalizeTemplate>>)
|
||||
const filteredTemplates = (app.templates as Array<ReturnType<typeof normalizeTemplate>>)
|
||||
.filter(template => !options.filter || options.filter(template))
|
||||
|
||||
await Promise.all(filteredTemplates
|
||||
.map(async (template) => {
|
||||
const contents = await compileTemplate(template, templateContext)
|
||||
|
||||
@ -55,7 +57,7 @@ export async function generateApp (nuxt: Nuxt, app: NuxtApp, options: { filter?:
|
||||
}
|
||||
}))
|
||||
|
||||
await nuxt.callHook('app:templatesGenerated', app)
|
||||
await nuxt.callHook('app:templatesGenerated', app, filteredTemplates, options)
|
||||
}
|
||||
|
||||
async function resolveApp (nuxt: Nuxt, app: NuxtApp) {
|
||||
|
@ -123,7 +123,7 @@ export interface NuxtHooks {
|
||||
* @param app The configured `NuxtApp` object
|
||||
* @returns Promise
|
||||
*/
|
||||
'app:templatesGenerated': (app: NuxtApp) => HookResult
|
||||
'app:templatesGenerated': (app: NuxtApp, templates: ResolvedNuxtTemplate[], options?: GenerateAppOptions) => HookResult
|
||||
|
||||
/**
|
||||
* Called before Nuxt bundle builder.
|
||||
|
Loading…
Reference in New Issue
Block a user