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(content): pass document data to remark plugins #782

Merged
merged 4 commits into from
Mar 1, 2021
Merged

feat(content): pass document data to remark plugins #782

merged 4 commits into from
Mar 1, 2021

Conversation

farnabaz
Copy link
Member

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

This is a proposal PR to inject document data into remark plugins. Plugins may read/modify document data.

resolves #781

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes (if not applicable, please state why)

@farnabaz farnabaz marked this pull request as ready for review February 18, 2021 17:08
@atinux atinux requested review from benjamincanac and pi0 February 19, 2021 08:26
@atinux
Copy link
Member

atinux commented Feb 19, 2021

Could you add a small exemple in the docs regarding the remark plugins to understand the advantage of having the document data?

@farnabaz
Copy link
Member Author

I add a simple plugin:

  • it detects <authors> tag in content
  • find the original file path
  • fetch contributors of file form Github api
  • inject data into document data and update tag

SandBox: https://codesandbox.io/s/suspicious-leavitt-ygg26?file=/example/utils/contributors.js
Result: https://ygg26.sse.codesandbox.io/authors

Copy link
Member

atinux commented Feb 22, 2021

It looks great 😍

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

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.

Allow remark plugin to modify document data
3 participants