-
Notifications
You must be signed in to change notification settings - Fork 140
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
Support custom Provider #10
Conversation
Hey @devrsi0n - this looks like a great addition, could you add a little more context on why this might be a helpful feature, and document it in the README as well? 🙏🏼 |
- `renderToString(source: string, components: object)` - This function consumes a string of mdx along with any components it utilizes in the format `{ ComponentName: ActualComponent }`. The function returns an object that is intended to be passed into `hydrate` directly. | ||
- `hydrate(source: object, components: object, options?: object)` - This function consumes the output of `renderToString` as well as the same components argument as `renderToString`. It also can optionally be passed options which are [passed directly to mdx](https://mdxjs.com/advanced/plugins). Its result can be rendered directly into your component. This function will initially render static content, and hydrate it when the browser isn't busy with higher priority tasks. | ||
- `renderToString(source: string, components: object, options?: object)` - This function consumes a string of mdx along with any components it utilizes in the format `{ ComponentName: ActualComponent }`. The function returns an object that is intended to be passed into `hydrate` directly. It also can optionally be passed options which are [passed directly to mdx](https://mdxjs.com/advanced/plugins), `options.remarkPlugins` for reamrk plugins, `options.rehypePlugins` for rehype plugins, and `options.Provider` for custom provider (e.g. [emotion theme provider](https://emotion.sh/docs/theming)) | ||
- `hydrate(source: object, components: object)` - This function consumes the output of `renderToString` as well as the same components argument as `renderToString`. Its result can be rendered directly into your component. This function will initially render static content, and hydrate it when the browser isn't busy with higher priority tasks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems options
should place to renderToString
, could you confirm that? @jescalan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct, this was fixed upstream though, so it can be rebased out
This should be ready to go pending a rebase on upstream/master! |
@ynnoj - it would allow you to pass in a provider via the options, but would not automatically inherit from any provider above in the tree. another option is to pass in data using the |
Local context wouldn't be available within the |
@ynnoj That's correct - really the answer depends on how you're adding data to the context. I would be happy to work with you on figuring out how to solve this if you'd like, as I anticipate having the same problem myself down the line with auth/user context. |
Hey folks! Just stumbled across this PR and it would seem it might be an answer to a problem we are having with using mdx-embed with NEXT (via this package) Any movement on a merge? |
Yes, there will be a resolution to this issue shipped this week. Likely tonight. |
#35 supersedes this |
Add an option to support custom Provider.