mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 17:07:22 +00:00
fix(nuxt): don't warn about definePageMeta
in server pages (#26422)
This commit is contained in:
parent
4a880cb693
commit
4647d2f925
@ -3,6 +3,7 @@ import { getCurrentInstance } from 'vue'
|
|||||||
import type { RouteLocationNormalized, RouteLocationNormalizedLoaded, RouteRecordRedirectOption } from '#vue-router'
|
import type { RouteLocationNormalized, RouteLocationNormalizedLoaded, RouteRecordRedirectOption } from '#vue-router'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import type { NitroRouteConfig } from 'nitropack'
|
import type { NitroRouteConfig } from 'nitropack'
|
||||||
|
import { useNuxtApp } from '#app/nuxt'
|
||||||
import type { NuxtError } from '#app'
|
import type { NuxtError } from '#app'
|
||||||
|
|
||||||
export interface PageMeta {
|
export interface PageMeta {
|
||||||
@ -58,8 +59,9 @@ export const definePageMeta = (meta: PageMeta): void => {
|
|||||||
const component = getCurrentInstance()?.type
|
const component = getCurrentInstance()?.type
|
||||||
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))
|
||||||
if (isRouteComponent) {
|
const isRenderingServerPage = import.meta.server && useNuxtApp().ssrContext?.islandContext
|
||||||
// don't warn if it's being used in a route component
|
if (isRouteComponent || isRenderingServerPage) {
|
||||||
|
// don't warn if it's being used in a route component (or server page)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
Reference in New Issue
Block a user