web-garden icon indicating copy to clipboard operation
web-garden copied to clipboard

Allow astro-diagram to set `id` for call to `mermaidAPI.render`

Open voidmain opened this issue 1 year ago • 0 comments

Currently, it looks like the code that generates the Mermaid diagram is not passing in anything for the id parameter. This causes Mermaid to use the default id of diagram. This will conflict with other elements on the page that have the same id.

You could allow a new property on the Diagram element that allows the id to be specified like this:

<Diagram id="foo" code={code} config={config}/>

The code change would be in the file https://github.com/JulianCataldo/web-garden/blob/develop/components/Diagram/Diagram.astro on line 24:

id: props.id

You'll need to handle the safeguards as well. I'm happy to submit a PR if you prefer. 😁

voidmain avatar Apr 26 '23 15:04 voidmain