mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-15 02:14:44 +00:00
fix(nuxt): respect existing props
value in definePageMeta
(#29683)
This commit is contained in:
parent
2aa4daab92
commit
cbafa582a3
@ -507,13 +507,14 @@ export function normalizeRoutes (routes: NuxtPage[], metaImports: Set<string> =
|
|||||||
|
|
||||||
const route: NormalizedRoute = {
|
const route: NormalizedRoute = {
|
||||||
path: serializeRouteValue(page.path),
|
path: serializeRouteValue(page.path),
|
||||||
|
props: serializeRouteValue(page.props),
|
||||||
name: serializeRouteValue(page.name),
|
name: serializeRouteValue(page.name),
|
||||||
meta: serializeRouteValue(metaFiltered, skipMeta),
|
meta: serializeRouteValue(metaFiltered, skipMeta),
|
||||||
alias: serializeRouteValue(toArray(page.alias), skipAlias),
|
alias: serializeRouteValue(toArray(page.alias), skipAlias),
|
||||||
redirect: serializeRouteValue(page.redirect),
|
redirect: serializeRouteValue(page.redirect),
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const key of ['path', 'name', 'meta', 'alias', 'redirect'] satisfies NormalizedRouteKeys) {
|
for (const key of ['path', 'props', 'name', 'meta', 'alias', 'redirect'] satisfies NormalizedRouteKeys) {
|
||||||
if (route[key] === undefined) {
|
if (route[key] === undefined) {
|
||||||
delete route[key]
|
delete route[key]
|
||||||
}
|
}
|
||||||
@ -542,7 +543,7 @@ export function normalizeRoutes (routes: NuxtPage[], metaImports: Set<string> =
|
|||||||
const metaRoute: NormalizedRoute = {
|
const metaRoute: NormalizedRoute = {
|
||||||
name: `${metaImportName}?.name ?? ${route.name}`,
|
name: `${metaImportName}?.name ?? ${route.name}`,
|
||||||
path: `${metaImportName}?.path ?? ${route.path}`,
|
path: `${metaImportName}?.path ?? ${route.path}`,
|
||||||
props: `${metaImportName}?.props ?? false`,
|
props: `${metaImportName}?.props ?? ${route.props ?? false}`,
|
||||||
meta: `${metaImportName} || {}`,
|
meta: `${metaImportName} || {}`,
|
||||||
alias: `${metaImportName}?.alias || []`,
|
alias: `${metaImportName}?.alias || []`,
|
||||||
redirect: `${metaImportName}?.redirect`,
|
redirect: `${metaImportName}?.redirect`,
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
"meta": "mockMeta || {}",
|
"meta": "mockMeta || {}",
|
||||||
"name": "mockMeta?.name ?? "page-with-props"",
|
"name": "mockMeta?.name ?? "page-with-props"",
|
||||||
"path": "mockMeta?.path ?? "/page-with-props"",
|
"path": "mockMeta?.path ?? "/page-with-props"",
|
||||||
"props": "mockMeta?.props ?? false",
|
"props": "mockMeta?.props ?? true",
|
||||||
"redirect": "mockMeta?.redirect",
|
"redirect": "mockMeta?.redirect",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
"component": "() => import("pages/page-with-props.vue")",
|
"component": "() => import("pages/page-with-props.vue")",
|
||||||
"name": ""page-with-props"",
|
"name": ""page-with-props"",
|
||||||
"path": ""/page-with-props"",
|
"path": ""/page-with-props"",
|
||||||
|
"props": "true",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"should allow pages with `:` in their path": [
|
"should allow pages with `:` in their path": [
|
||||||
|
Loading…
Reference in New Issue
Block a user