fix(nuxt): warn when definePageMeta does not receive an object (#31156)

This commit is contained in:
Julien Huang 2025-02-27 23:19:04 +01:00 committed by Daniel Roe
parent a4e6069a4b
commit fb52196453
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

@ -247,7 +247,10 @@ export async function getRouteMeta (contents: string, absolutePath: string, extr
foundMeta = true
const pageMetaArgument = node.expression.arguments[0]
if (pageMetaArgument?.type !== 'ObjectExpression') { return }
if (pageMetaArgument?.type !== 'ObjectExpression') {
logger.warn(`\`definePageMeta\` must be called with an object literal (reading \`${absolutePath}\`).`)
return
}
for (const key of extractionKeys) {
const property = pageMetaArgument.properties.find((property): property is Property => property.type === 'Property' && property.key.type === 'Identifier' && property.key.name === key)