vitepress
vitepress copied to clipboard
Can expose the frontmatter to the md object?
Is your feature request related to a problem? Please describe.
I write a VirePress md plugin in this project. And i wanted to use frontmatter data in the markdown plugin, but I had to re-parse the file contents to get it.
It would be much better to expose frontmatter to md object like md.__path
md.renderer.rules.html_block = (tokens, idx, ...args) => {
...
const mdContent = fsExtra.readFileSync(md.__path);
const { data: frontmatter } = matter(mdContent);
...
};
Describe the solution you'd like
https://github.com/vuejs/vitepress/blob/main/src/node/markdownToVue.ts#L69
const { content, data: frontmatter } = matter(src)
md.__path = file
md.__relativePath = relativePath
// add this
md.__frontmatter = frontmatter
Describe alternatives you've considered
No response
Additional context
No response
Validations
- [X] Follow our Code of Conduct
- [X] Read the docs.
- [X] Read the Contributing Guidelines.
- [X] Check that there isn't already an issue that asks for the same feature to avoid creating a duplicate.
#856 will fix this