fix(nuxt): merge and apply layer hooks (#24639)

This commit is contained in:
Daniel Roe 2023-12-08 13:51:57 +01:00 committed by GitHub
parent 2193891778
commit 0c832465ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,7 +51,11 @@ export function createNuxt (options: NuxtOptions): Nuxt {
async function initNuxt (nuxt: Nuxt) {
// Register user hooks
nuxt.hooks.addHooks(nuxt.options.hooks)
for (const config of nuxt.options._layers.map(layer => layer.config).reverse()) {
if (config.hooks) {
nuxt.hooks.addHooks(config.hooks)
}
}
// Set nuxt instance for useNuxt
nuxtCtx.set(nuxt)