mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +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 { useRoute } from 'vue-router'
|
||||
import type { NitroRouteConfig } from 'nitropack'
|
||||
import { useNuxtApp } from '#app/nuxt'
|
||||
import type { NuxtError } from '#app'
|
||||
|
||||
export interface PageMeta {
|
||||
@ -58,8 +59,9 @@ export const definePageMeta = (meta: PageMeta): void => {
|
||||
const component = getCurrentInstance()?.type
|
||||
try {
|
||||
const isRouteComponent = component && useRoute().matched.some(p => Object.values(p.components || {}).includes(component))
|
||||
if (isRouteComponent) {
|
||||
// don't warn if it's being used in a route component
|
||||
const isRenderingServerPage = import.meta.server && useNuxtApp().ssrContext?.islandContext
|
||||
if (isRouteComponent || isRenderingServerPage) {
|
||||
// don't warn if it's being used in a route component (or server page)
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
|
Loading…
Reference in New Issue
Block a user