mdx-js / mdx

Markdown for the component era
https://mdxjs.com
MIT License
17.71k stars 1.14k forks source link

YAML support #1069

Closed vixalien closed 4 years ago

vixalien commented 4 years ago

YAML Support

I was digging through mdast and saw one component: YAML, which can be very important.

Problem

Missing YAML markup to create front-matter.

Expected behavior

We should be able to write code like:

---
foo: bar
---

which can be passed as YAML as the following data

{type: 'yaml', value: 'foo: bar'}

Alternatives

The current alternatives are using export const meta = {...} which disturbs some use of pure-md and involve the use of JS which is very depressing in case of very many markdown files.

End notes

We can try to implement this, if there is no problem.

wooorm commented 4 years ago

I believe you can add support for frontmatter in MDX by using the remark-frontmatter plugin!

johno commented 4 years ago

Yeah, this is something you should be able to achieve in user land with a plugin as @wooorm brings up. We also have a guide using a custom loader to add frontmatter support: https://mdxjs.com/guides/custom-loader

Other frameworks that use MDX often have frontmatter support built in, too, like gatsby-plugin-mdx.

As such, I'm going to close this for now, but please reach out to use if this doesn't suffice.