Closed devidw closed 1 year ago
Never mind, just figured out that the Svelte Context API is a great use for this case.
Wrapping each svelte-markdown component into a separate component that receives the prop and sets it to the context, which can then be received by the custom renderer.
Hey, thanks creating this. 🎉
When using custom renderers, is there a way to add custom props to those?
A use case would be to render multiple instances in a loop, and each renderer should have access to the item of the current loop iteration.
In the above example, I would like to use the data of
item
in theCodeRenderer
component.I played around with a local fork of this package and modified the entry point component and parser component to pass down the
{...$$restProps}
to the components that are created by the parser.This way, it would be possible to pass down the prop via:
However, I am wondering if there might be a better way to do this, or if you would welcome a PR to add these modifications?
Wdyt? Thanks 🙌