Access frontmatter after compile
with outputFormat: "function-body"
#2468
-
Dear mdx-js community I wonder if I can access the frontmatter when I I've read https://mdxjs.com/guides/frontmatter/ and loaded already Thank you for your help |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Yes, you should be able to access it when running when you use both those two plugins. Do a |
Beta Was this translation helpful? Give feedback.
-
You can use |
Beta Was this translation helpful? Give feedback.
That’s what
vfile-matter
indeed does!compile
indeed returns a vfile, with the compiled javascript as a result.It also accepts a vfile, with the input markdown/mdx (with/without frontmatter).
You can put
vfile-matter
in a plugin, and pass that tocompile
. Then you get what you want too.Or you can create a vfile first, call
vfile-matter
with that file, and pass that file tocompile
. That’s what I’d do.