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
Section titled βExampleβThe following d2 markdown code block:
direction: rightx -> y -> z: hellowill produce the diagram:
Enabling D2
Section titled β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_GENERATEenvironment setting is configured which controls whether thed2command will be called to create diagrams fromd2markdown code blocks.falseis the default value and appropriate for CI buildstrueis an appropriate value for a local.envfile since developers will generate diagrams only when building locally
Note that the d2 command must be installed for local development.