Skip to content

Commit

Permalink
Merge pull request #26 from simon-siggaard/main
Browse files Browse the repository at this point in the history
add support for Mermaid diagrams
  • Loading branch information
tomfran authored Sep 21, 2024
2 parents 598717d + 7a7c68d commit 548d67b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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 }}
10 changes: 9 additions & 1 deletion layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ <h1 class="single-title">{{ .Title }}</h1>
{{ end }}
</div>

{{ if .Store.Get "hasMermaid" }}
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
{{ end }}


{{/* Next prev controls */}}

{{ if not (.Param "hidePagination") }}
Expand All @@ -88,4 +96,4 @@ <h1 class="single-title">{{ .Title }}</h1>

</div>

{{ end }}
{{ end }}

0 comments on commit 548d67b

Please sign in to comment.