Display d2 diagrams in Hexo blog posts.
To use this plugin, you need to install the d2 diagramming tool:
curl -fsSL https://d2lang.com/install.sh | sh -s --
Next, add the hexo-d2 plugin to your Hexo project:
npm install hexo-d2 --save
To display D2 diagrams, you can use a syntax similar to Mermaid. Add code blocks with the d2 language identifier:
```d2
Stage One -> Stage Two -> Stage Three -> Stage Four
Stage Four -> Stage One: repeat
```
The diagram will be rendered and displayed as an SVG:
The command used to generate SVGs from D2 files is:
d2 <d2file> <svgfile> --pad 10
You can customize the HTML template for displaying the SVGs as needed. The default format is:
<div class="d2-diagram" style="width: 30%; margin: auto;">${svgContent}</div>
Feel free to adjust the command or HTML to match your specific requirements.
This plugin is licensed under the CC BY-NC-SA 4.0 license.