mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(nuxt): don't warn for definePageMeta
in client-only pages (#28246)
This commit is contained in:
parent
dd50c3f41d
commit
c5d524adb0
@ -4,7 +4,13 @@ import ClientOnly from '#app/components/client-only'
|
|||||||
|
|
||||||
/* @__NO_SIDE_EFFECTS__ */
|
/* @__NO_SIDE_EFFECTS__ */
|
||||||
export const createClientPage = (loader: AsyncComponentLoader) => {
|
export const createClientPage = (loader: AsyncComponentLoader) => {
|
||||||
const page = defineAsyncComponent(loader)
|
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({
|
return defineComponent({
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
|
@ -60,7 +60,7 @@ export const definePageMeta = (meta: PageMeta): void => {
|
|||||||
try {
|
try {
|
||||||
const isRouteComponent = component && useRoute().matched.some(p => Object.values(p.components || {}).includes(component))
|
const isRouteComponent = component && useRoute().matched.some(p => Object.values(p.components || {}).includes(component))
|
||||||
const isRenderingServerPage = import.meta.server && useNuxtApp().ssrContext?.islandContext
|
const isRenderingServerPage = import.meta.server && useNuxtApp().ssrContext?.islandContext
|
||||||
if (isRouteComponent || isRenderingServerPage) {
|
if (isRouteComponent || isRenderingServerPage || ((component as any)?.__clientOnlyPage)) {
|
||||||
// don't warn if it's being used in a route component (or server page)
|
// don't warn if it's being used in a route component (or server page)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user