Skip to content

Commit c8674eb

Browse files
authored
Render mermaid via code blocks, instead of shortcodes (#338)
1 parent 84b02ce commit c8674eb

File tree

4 files changed

+27
-25
lines changed

4 files changed

+27
-25
lines changed

doc/content/features.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,25 @@ To use them elsewhere, e.g. in Hugo templates, we provide an `svg-icon` partial.
124124
```
125125
{{ partial "svg-icon" "my-icon" }}
126126
```
127+
128+
## Mermaid diagrams
129+
130+
[Mermaid](https://mermaid.js.org/) diagrams are rendered from code blocks:
131+
132+
````md
133+
```mermaid
134+
graph LR
135+
A[Square Rect] -- Link text --> B((Circle))
136+
A --> C(Round Rect)
137+
B --> D{Rhombus}
138+
C --> D
139+
```
140+
````
141+
142+
```mermaid
143+
graph LR
144+
A[Square Rect] -- Link text --> B((Circle))
145+
A --> C(Round Rect)
146+
B --> D{Rhombus}
147+
C --> D
148+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<pre class="mermaid">
2+
{{- .Inner | safeHTML }}
3+
</pre>
4+
{{ .Page.Store.Set "hasMermaid" true }}

layouts/partials/javascript.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</script>
3737
{{ end -}}
3838

39-
{{- if .HasShortcode "mermaid" }}
39+
{{- if .Page.Store.Get "hasMermaid" }}
4040
<script type="module">
4141
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10.4.0/dist/mermaid.esm.min.mjs';
4242

layouts/shortcodes/mermaid.html

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)