#Nuxt Content 2 places custom bindings under "meta"

1 messages · Page 1 of 1 (latest)

steady tundra
#

I have copied example from https://content.nuxt.com/docs/files/markdown#define-in-yaml and didn't quite understand why $doc.customVariable kept becoming empty on page.
After using devtools I found that frontmatter defined customVariable is actually under $doc.meta.customVariable

It is very confusing that custom variables are being placed under meta attribute - is this indended behavior that current docs just don't quite cover right now?

Nuxt Content

Create and query Markdown files in your Nuxt applications and use the MDC syntax to integrate Vue components.

remote daggerBOT
#

Hi @steady tundra. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The knowledge sources you provided don’t include Nuxt Content’s front‑matter mapping rules, so I can’t confirm the exact intended behavior from the official docs.

From what is documented, Nuxt uses a meta object in several places for route/page metadata (definePageMetaroute.meta, etc.). [Page metadata; definePageMeta meta] This suggests that putting additional, non-core fields under a meta key is a common pattern in Nuxt, but the provided sources do not explicitly state that Nuxt Content 2 front‑matter is intentionally nested under $doc.meta.

So:

  • Your observation that customVariable is available as $doc.meta.customVariable is consistent with Nuxt’s general use of meta objects.
  • However, I cannot confirm from these sources whether this is the documented, intended Nuxt Content 2 behavior or just an implementation detail that the current Content docs don’t clearly describe.

Given that gap, the safest assumption (based only on these sources) is:

  • Access your custom front‑matter via $doc.meta.customVariable.
  • Treat this as aligned with Nuxt’s broader “meta” convention, but be aware the specific Nuxt Content behavior is not clearly covered in the docs we have here.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: