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

Can expose the frontmatter to the md object? #1122

Closed
4 tasks done
dewfall123 opened this issue Aug 5, 2022 · 1 comment · Fixed by #856
Closed
4 tasks done

Can expose the frontmatter to the md object? #1122

dewfall123 opened this issue Aug 5, 2022 · 1 comment · Fixed by #856
Labels
build Related to the build system enhancement New feature or request

Comments

@dewfall123
Copy link
Contributor

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

@brc-dd
Copy link
Member

brc-dd commented Aug 5, 2022

#856 will fix this

@brc-dd brc-dd added enhancement New feature or request build Related to the build system labels Aug 5, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
build Related to the build system enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants