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

d2 support #963

Closed
a-h opened this issue Apr 19, 2023 · 4 comments
Closed

d2 support #963

a-h opened this issue Apr 19, 2023 · 4 comments
Labels

Comments

@a-h
Copy link
Contributor

a-h commented Apr 19, 2023

I'm finding Terrastruct's D2 to be really useful for architecture diagrams and I'd love for it to be better integrated into slidev.

https://github.com/terrastruct/d2

Describe the solution you'd like

Ideally, I'd be able to have the D2 diagram code in the slidev project, and it would be updated automatically, like mermaid.js

Describe alternatives you've considered

At the moment, to use it, I create diagrams in /diagrams, e.g. /diagrams/08-dead-letter.d2

style: {
  fill: transparent
}

direction: right

lambda: Lambda
lambda: {
  icon: https://icons.terrastruct.com/aws%2FCompute%2FAWS-Lambda.svg
}
sqs: SQS DLQ
sqs: {
  icon: https://icons.terrastruct.com/aws%2FApplication%20Integration%2FAmazon-Simple-Queue-Service-SQS.svg
}
eb: "EventBridge"
eb: {
  icon: https://icons.terrastruct.com/aws%2FApplication%20Integration%2FAmazon-EventBridge.svg
}
cloudwatch: CloudWatch Alarm
cloudwatch: {
  icon: https://icons.terrastruct.com/aws%2FManagement%20&%20Governance%2FAmazon-CloudWatch.svg
}
sns: SNS
sns: {
  icon: https://icons.terrastruct.com/aws%2FApplication%20Integration%2FAmazon-Simple-Notification-Service-SNS.svg
}
eb -> lambda: event
lambda -> sqs: onFailure
sqs <- cloudwatch: Check depth
cloudwatch -> sns: Notify OpsGenie

Then run a script in that directory to generate everything and move it to public.

ls *.d2 | xargs -I {} ~/go/bin/d2 --layout=elk --theme=200 {}
mv *.svg ../public

I then have to put a link to the SVG diagram in my presentation.

<img src="/01-static.svg" style="width: 100%; height: 100%;" />

It's OK, but native support would be ideal.

@twitwi
Copy link
Contributor

twitwi commented Apr 28, 2023

Very interesting.
There seem to already be a browser (WASM) build of d2, used for the playground (and currently being improved terrastruct/d2#436 ) so it could be directly integrated in the browser, like mermaid, without running external tools.

@stale
Copy link

stale bot commented Jun 27, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 27, 2023
@stale stale bot closed this as completed Jul 9, 2023
@hacker1024
Copy link

Can this be re-opened?

@kermanx
Copy link
Member

kermanx commented Jul 29, 2024

Can this be re-opened?

Markdown transformer is now supported. Making an addon that renders D2 diagrams in your slides is possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants