mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-09 03:03:18 +00:00
26 lines
732 B
TypeScript
26 lines
732 B
TypeScript
import { defineAsyncComponent, defineComponent, h } from 'vue'
|
|
import type { AsyncComponentLoader } from 'vue'
|
|
import ClientOnly from '#app/components/client-only'
|
|
|
|
/* @__NO_SIDE_EFFECTS__ */
|
|
export const createClientPage = (loader: AsyncComponentLoader) => {
|
|
const page = defineAsyncComponent(import.meta.dev
|
|
? () => loader().then((m) => {
|
|
// mark component as client-only for `definePageMeta`
|
|
(m.default || m).__clientOnlyPage = true
|
|
return m.default || m
|
|
})
|
|
: loader)
|
|
|
|
return defineComponent({
|
|
inheritAttrs: false,
|
|
setup (_, { attrs }) {
|
|
return () => h('div', [
|
|
h(ClientOnly, undefined, {
|
|
default: () => h(page, attrs),
|
|
}),
|
|
])
|
|
},
|
|
})
|
|
}
|