#Which formats are accepted for frontmatter in md/mdx/mdoc files?
3 messages · Page 1 of 1 (latest)
Hi @inner haven. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Astro supports frontmatter in Markdown (.md), MDX (.mdx), and Markdoc (.mdoc) files. The frontmatter is typically written in YAML format, as indicated in the Astro documentation (https://docs.astro.build/en/guides/markdown-content/#_top) and Starlight guide (https://starlight.astro.build/guides/authoring-content/#_top). There's no mention of support for other formats like TOML or JSON in the provided knowledge sources.
Astro provides a way to retrieve the frontmatter from the file content. For instance, in Markdown and MDX layouts, you can access frontmatter properties through Astro.props.frontmatter as shown in the Astro Basics guide (https://docs.astro.build/en/basics/layouts/#markdownmdx-layouts).
In addition, when loading Markdown files with Astro.glob(), the returned MarkdownInstance interface includes a frontmatter property that contains any data specified in the file's YAML frontmatter. You can optionally provide a type for the frontmatter variable using a TypeScript generic as shown in the Astro API reference (https://docs.astro.build/en/reference/api-reference/#markdown-files).