diff --git a/src/app/pages/_.vue b/src/app/pages/_.vue
index 26f0df043..76313e045 100644
--- a/src/app/pages/_.vue
+++ b/src/app/pages/_.vue
@@ -1,5 +1,5 @@
-
+
diff --git a/src/core/runtime/composables/helpers.ts b/src/core/runtime/composables/helpers.ts
index e34d8c010..2b6d064f6 100644
--- a/src/core/runtime/composables/helpers.ts
+++ b/src/core/runtime/composables/helpers.ts
@@ -7,25 +7,39 @@ export const docusInit = ({ context, state }: DocusAddonContext) => {
}
}
-export const clientAsyncData = (app, $nuxt: any) => {
+export const clientAsyncData = (_app, $nuxt: any) => {
if (process.client) {
+ const loadedComponents = new Set()
+ const loadComponents = function (components?: Set) {
+ if (!components) return
+ return Array.from(components).map(async function (name) {
+ if (!loadedComponents.has(name) && typeof Vue.component(name) === 'function') {
+ loadedComponents.add(name)
+ try {
+ // @ts-ignore
+ await Vue.component(name)()
+ } catch (e) {}
+ }
+ })
+ }
window.onNuxtReady((nuxt: any) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
$nuxt = nuxt
- // Workaround since in full static mode, asyncData is not called anymore
- app.router.beforeEach((_: any, __: any, next: any) => {
- const payload = nuxt._pagePayload || {}
+ // Workaround for Vue 2 since does not exists
+ const originalFetchPayload = $nuxt.fetchPayload
+ if (originalFetchPayload) {
+ $nuxt.fetchPayload = async function (...args) {
+ const payload = await originalFetchPayload(...args)
- payload.data = payload.data || []
+ await loadComponents(payload.fetch?._lazyComponents)
+ await loadComponents(new Set(payload.data[0]?.page?.template))
- if (payload.data[0]?.page?.template && typeof Vue.component(payload.data[0].page.template) === 'function') {
- // Preload the component on client-side navigation
- Vue.component(payload.data[0].page.template)
+ return payload
}
-
- next()
- })
+ }
+ // Fetch NuxtContent component
+ loadComponents(new Set('NuxtContent'))
})
}
}