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

feat: 192 Expose RawDocumentData on vFile data field for Markdown/MDX Files #195

Conversation

Saeris
Copy link

@Saeris Saeris commented Apr 26, 2022

Implementation for the request in #192 that also partially solves for #11.

In @contentlayer/core I added a new data field to the options argument of markdownToHtml and bundleMDX which can be used to pass arbitrary data to the resulting document's vFile 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 both markdownToHtml and bundleMDX. 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 the source-files package, as I'm unsure whether other sources like source-contentful expose the same RawDocumentData 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.

Implementation for the request in contentlayerdev#192 that also partially solves for contentlayerdev#11.

In `@contentlayer/core` I added a new `data` field to the  options argument of `markdownToHtml` and `bundleMDX` which can be used to pass arbitrary data to the resulting document's `vFile` `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 both `markdownToHtml` and `bundleMDX`. 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 the `source-files` package, as I'm unsure whether other sources like `source-contentful` expose the same `RawDocumentData` 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.
@changeset-bot
Copy link

changeset-bot bot commented Apr 26, 2022

⚠️ No Changeset found

Latest commit: d3d35f2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Saeris Saeris changed the title 192 Expose RawDocumentData on vFile data field for Markdown/MDX Files feat: 192 Expose RawDocumentData on vFile data field for Markdown/MDX Files Apr 26, 2022
@schickling
Copy link
Collaborator

Thanks a lot for this PR. I've addressed the underlying problem/usecase with the upcoming 0.2.5 release. Closing this PR for now.

@schickling schickling closed this May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants