feat: 192 Expose RawDocumentData on vFile data
field for Markdown/MDX Files
#195
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implementation for the request in #192 that also partially solves for #11.
In
@contentlayer/core
I added a newdata
field to the options argument ofmarkdownToHtml
andbundleMDX
which can be used to pass arbitrary data to the resulting document'svFile
data
property.Not knowing how you want to structure utility functions for this library, in the initial implementation I've inlined the
addRawDocumentMeta
remark plugin used to append the vFile inside of bothmarkdownToHtml
andbundleMDX
. Please advise me if you'd like this extracted out to somewhere else instead.In this PR I've only updated the
mapping.ts
file for thesource-files
package, as I'm unsure whether other sources likesource-contentful
expose the sameRawDocumentData
that the filesystem source does. Other sources can pass whatever document metadata is pertinent to them to the markdown processors using this addition to their APIs.