Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(markdown): add support for TOML frontmatter in Markdown files. #12850

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

colinbate
Copy link

Changes

  • Changed the frontmatter parsing in @astrojs/markdown-remark to accept TOML format
  • Uses +++ as the delimiters
  • Doesn't require configuration
    • If the TOML delimiters are used it will parse as TOML
    • Otherwise defaults to YAML

Testing

Updated the frontmatter.test.js file, adding TOML equivalent tests alongside the existing YAML tests. Worth noting that the TOML test run notably faster, owing to the faster parsing

Docs

This is certainly something that should be documented. It allows you to use TOML based frontmatter, which is particularly useful if migrating from Hugo or another system that preferred TOML and you don't want to convert potentially thousands of files.

Works for content collections, or with standalone markdown files.

/cc @withastro/maintainers-docs for feedback!

@github-actions github-actions bot added the feat: markdown Related to Markdown (scope) label Dec 29, 2024
@colinbate colinbate changed the title Add support for TOML frontmatter in Markdown files. feat: add support for TOML frontmatter in Markdown files. Dec 31, 2024
@colinbate colinbate changed the title feat: add support for TOML frontmatter in Markdown files. feat(markdown): add support for TOML frontmatter in Markdown files. Dec 31, 2024
@ematipico
Copy link
Member

Why would we allow TOML frontmatter in .mdx files but not in .md files? It seems a missed opportunity

@colinbate
Copy link
Author

@ematipico Apologies, I didn't mean to imply this was only for MDX files. It works for both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: markdown Related to Markdown (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants