feat(nuxt): add renderResult to app:rendered (#18610)

This commit is contained in:
John Jenkins 2023-06-07 10:25:05 +01:00 committed by GitHub
parent 0bc38b7e19
commit 6bb0a849fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import type { RouteLocationNormalizedLoaded } from '#vue-router'
import type { HookCallback, Hookable } from 'hookable'
import { createHooks } from 'hookable'
import { getContext } from 'unctx'
import type { SSRContext } from 'vue-bundle-renderer/runtime'
import type { SSRContext, createRenderer } from 'vue-bundle-renderer/runtime'
import type { H3Event } from 'h3'
import type { AppConfig, AppConfigInput, RuntimeConfig } from 'nuxt/schema'
import type { RenderResponse } from 'nitropack'
@ -28,7 +28,7 @@ type NuxtMeta = {
type HookResult = Promise<void> | void
type AppRenderedContext = { ssrContext: NuxtApp['ssrContext'] }
type AppRenderedContext = { ssrContext: NuxtApp['ssrContext'], renderResult: null | Awaited<ReturnType<ReturnType<typeof createRenderer>['renderToString']>> }
export interface RuntimeNuxtHooks {
'app:created': (app: App<Element>) => HookResult
'app:beforeMount': (app: App<Element>) => HookResult

View File

@ -252,7 +252,7 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
await ssrContext.nuxt?.hooks.callHook('app:error', _err)
throw _err
})
await ssrContext.nuxt?.hooks.callHook('app:rendered', { ssrContext })
await ssrContext.nuxt?.hooks.callHook('app:rendered', { ssrContext, renderResult: _rendered })
if (ssrContext._renderResponse) { return ssrContext._renderResponse }