terrastruct / d2-playground

An online runner to play, learn, and create with D2, the modern diagram scripting language that turns text to diagrams.
https://play.d2lang.com
Mozilla Public License 2.0
71 stars 9 forks source link

Hope to add `/export/{format}` to render raw svg/png directly #20

Open morlay opened 1 year ago

morlay commented 1 year ago

Like mermaid.live did

https://mermaid.live/view#pako:eNptkMtqAzEMRX9F0bYzP-BFSqGFppBVt7NRPDcZgx-Jx6aEkH-PxtMuCvHqWjpHIN3YphFseMalIlq8OzllCUMkfW_eWfTb7ctXmqKhT3ifaMkdTemHJIOuqb4-hVfMSlwQmiCZAn7Rpdcr2jdHB7vV7mjXjEartnmO7-gIeDplSNlwxwE5iBt1i9siDFwmBAxsNB5k1jTEu3JSS_q-Rsum5IqO63mU8rfx_-LH6ErKbI7iZy2ifffrqdrF7g9-RmWe

Hope to add /export/{format} to render raw svg/png

https://play.d2lang.com/export/{format}?script=qlDQtVOo5AIEAAD__w%3D%3D&layout=dagre&theme=8

In this way, we could be easy to back to edit mode, with the shared link.

https://play.d2lang.com?script=qlDQtVOo5AIEAAD__w%3D%3D&layout=dagre&theme=8

alixander commented 1 year ago

@morlay Yup, D2 will soon have this. E.g. https://github.com/alixander/test-render/edit/main/README.md

morlay commented 1 year ago

@alixander looks good. but now seems got 403 error when visit directly.

https://api.d2lang.com/render/svg?script=qlDQtVOo5AIEAAD__w==&layout=dagre&theme=101&sketch=1

alixander commented 1 year ago

yes, it's whitelisted to only allow from playground and github right now. Do you have somewhere else specific you'd like to access the api from or are you just testing? @morlay

morlay commented 1 year ago

@alixander

Now just testing, but hope it could be embed in other doc systems in future.

I found kroki already start to support d2 https://github.com/yuzutech/kroki/pull/1414 If d2-playground have github limited, I have to wait the next release of kroki.