Skip to content

Commit

Permalink
Render mermaid via code blocks, instead of shortcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanv committed Oct 30, 2023
1 parent 84b02ce commit 41326f6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
22 changes: 22 additions & 0 deletions doc/content/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,25 @@ To use them elsewhere, e.g. in Hugo templates, we provide an `svg-icon` partial.
```
{{ partial "svg-icon" "my-icon" }}
```

## Mermaid diagrams

[Mermaid](https://mermaid.js.org/) diagrams are rendered from code blocks:

````md
```mermaid
graph LR
A[Square Rect] -- Link text --> B((Circle))
A --> C(Round Rect)
B --> D{Rhombus}
C --> D
```
````

```mermaid
graph LR
A[Square Rect] -- Link text --> B((Circle))
A --> C(Round Rect)
B --> D{Rhombus}
C --> D
```
4 changes: 4 additions & 0 deletions layouts/_default/_markup/render-codeblock-mermaid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<pre class="mermaid">
{{- .Inner | safeHTML }}
</pre>
{{ .Page.Store.Set "hasMermaid" true }}
2 changes: 1 addition & 1 deletion layouts/partials/javascript.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</script>
{{ end -}}

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

Expand Down
24 changes: 0 additions & 24 deletions layouts/shortcodes/mermaid.html

This file was deleted.

0 comments on commit 41326f6

Please sign in to comment.