Install the addon with npm:
npm install slidev-addon-d2-diagramEnable the addon in your Slidev slides.md frontmatter:
---
addons:
- slidev-addon-d2-diagram
---To create a D2 diagram, start a code block with ``` and enter d2 to activate the D2 diagram drawing feature.
```d2
direction: right
a -> b -> c
b: {
direction: right
1 -> 2 -> 3
}
a: {
direction: left
foo -> bar
}
```
Add a space after the language tag ```d2 and input { key1: value1, key2: value2 }.
- Supported options:
layout: Layout engine to use ('dagre' | 'elk') [default: 'elk'].themeID: Theme ID to use [default: 0].sketch: Enable sketch mode [default: false].
```d2 { layout: dagre, themeID: 300, sketch: true }
direction: right
a -> b -> c
b: {
direction: right
1 -> 2 -> 3
}
a: {
direction: left
foo -> bar
}
```