Merge pull request #25178 from dvdksn/mermaid-codeblock-hook

layouts: render mermaid code blocks as diagrams
This commit is contained in:
David Karlsson
2026-05-27 14:49:57 +02:00
committed by GitHub
7 changed files with 1045 additions and 65 deletions
@@ -0,0 +1,5 @@
{{- .Page.Store.Set "mermaid" true -}}
<pre
class="mermaid not-prose my-4 flex justify-center bg-transparent"
data-pagefind-ignore
>{{- .Inner -}}</pre>
+4
View File
@@ -0,0 +1,4 @@
{{ $mermaid := resources.Get "js/mermaid.js"
| js.Build (dict "minify" true "targetPath" "mermaid.js")
}}
<script defer src="{{ $mermaid.Permalink }}"></script>
+4
View File
@@ -95,5 +95,9 @@
{{ with .Store.Get "youtube" }}
{{ partialCached "youtube-script.html" "-" "-" }}
{{ end }}
{{/* Load mermaid if the page contains a mermaid code block */}}
{{ with .Store.Get "mermaid" }}
{{ partialCached "mermaid-script.html" "-" "-" }}
{{ end }}
</body>
</html>