D2: Declarative Diagramming
D2: Declarative Diagramming is a Diagrams as Code tool that converts code into diagrams. Check out their Cheat Sheet to learn more.
Example
The following d2
markdown code block:
direction: rightx -> y -> z: hello
will produce the diagram:
Enabling D2
When you choose D2 as an option, two things are added to the Starlight project:
- Astro D2 plugin is added as an Astro integration.
VITE_D2_GENERATE
environment setting is configured which controls whether thed2
command will be called to create diagrams fromd2
markdown code blocks.false
is the default value and appropriate for CI buildstrue
is an appropriate value for a local.env
file since developers will generate diagrams only when building locally
Note that the d2
command must be installed for local development.