fix(nuxt): fix syntax error when serializing route meta (#25515)

This commit is contained in:
Bobbie Goede 2024-01-31 10:54:01 +01:00 committed by GitHub
parent b485012f22
commit 50d69bff3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 32 additions and 1 deletions

View File

@ -457,7 +457,7 @@ export function normalizeRoutes (routes: NuxtPage[], metaImports: Set<string> =
}
} else {
if (route.meta != null) {
metaRoute.meta = `{ ...(${metaImportName}) || {}), ...${route.meta} }`
metaRoute.meta = `{ ...(${metaImportName} || {}), ...${route.meta} }`
}
if (route.alias != null) {

View File

@ -1,4 +1,14 @@
{
"pushed route, skips generation from file": [
{
"alias": "["pushed-route-alias"].concat(mockMeta?.alias || [])",
"component": "() => import("pages/route-file.vue").then(m => m.default || m)",
"meta": "{ ...(mockMeta || {}), ...{"someMetaData":true} }",
"name": "mockMeta?.name ?? "pushed-route"",
"path": "mockMeta?.path ?? "/"",
"redirect": "mockMeta?.redirect",
},
],
"route without file": [
{
"alias": "["sweet-home"]",

View File

@ -1,4 +1,13 @@
{
"pushed route, skips generation from file": [
{
"alias": "["pushed-route-alias"]",
"component": "() => import("pages/route-file.vue").then(m => m.default || m)",
"meta": "{"someMetaData":true}",
"name": ""pushed-route"",
"path": ""/"",
},
],
"route without file": [
{
"alias": "["sweet-home"]",

View File

@ -542,6 +542,18 @@ describe('pages:generateRoutesFromFiles', () => {
}
]
},
{
description: 'pushed route, skips generation from file',
output: [
{
name: 'pushed-route',
path: '/',
alias: ['pushed-route-alias'],
meta: { someMetaData: true },
file: `${pagesDir}/route-file.vue`,
}
]
},
]
const normalizedResults: Record<string, any> = {}