Use Frontmatter for imports.
See original GitHub issueReally awesome project. I think makes sense to separate imports from markup. One way to do this would be to use frontmatter – a concept made popular by Jekyll and a few other projects.
---
import: { Chart } from '../components/chart'
---
# Here's a chart
The chart is rendered inside our MDX document.
<Chart />
I wonder if anyone else has thoughts on this?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Frontmatter - MDX
This guide explores how to support YAML frontmatter in MDX. ... and dynamic alternative to frontmatter, namely ESM ( import / export )....
Read more >node.js - How to import Frontmatter & Markdown in JavaScript ...
Here is my simple JavaScript test: import home from '../pages/home.md'; console. log('testing'); console. log(home);
Read more >Customizing input and output - Python Frontmatter
loads , frontmatter first needs to figure out the best handler for the format you're using (YAML, JSON, TOML, etc), then call methods...
Read more >Importing markdown that has frontmatter : r/logseq - Reddit
We use it in Obisidian, either Frontmatter or the note's body.
Read more >Adding Metadata Using Markdown Frontmatter in NextJS
Once processed, the frontmatter will be available in .data.frontmatter on the vFile that was passed to the processor. import unified from " ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FWIW we decided against using front matter early on. I was originally in favor of it, but now think that MDX is much better without it. That said, it’s not too difficult to set up your own custom loader in front of the mdx-loader if you want to use front matter in your project, as is done here https://github.com/c8r/x0/blob/master/lib/mdx-fm-loader.js
Yeah, I don’t see a need for this either. That would be a new synax we’d need to implement and parse without a clear benefit. Import/export takes care of everything already, which is also a standardized syntax, like YAML.