You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hugo's documentation supports Mermaid Diagrams via Mermaid JS and I was hoping we could get this added to the theme.
I was able to get this working locally with the diff below. I'm pretty new to Hugo, so I'm unsure if this is the best place to add this functionality (specifically within single.html).
diff --git a/layouts/_default/_markup/render-codeblock-mermaid.html b/layouts/_default/_markup/render-codeblock-mermaid.html
new file mode 100644
index 0000000..7e12ad7
--- /dev/null+++ b/layouts/_default/_markup/render-codeblock-mermaid.html@@ -0,0 +1,4 @@+<pre class="mermaid">+ {{- .Inner | safeHTML }}+</pre>+ {{ .Page.Store.Set "hasMermaid" true }}
\ No newline at end of file
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 19a624f..860fe56 100644
--- a/layouts/_default/single.html+++ b/layouts/_default/single.html@@ -42,6 +42,13 @@
</div>
{{- end }}
+ {{ if .Page.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 }}+
<footer class="post-footer">
{{- $tags := .Language.Params.Taxonomies.tag | default "tags" }}
<ul class="post-tags">
I'll create a PR shortly for review, would appreciate any feedback or guidance!
The text was updated successfully, but these errors were encountered:
**NOTE**: PaperMod does not have any external dependencies fetched from 3rd party
CDN servers. However we do have custom Head/Footer extender templates which you can use
to add those to your website.
https://github.com/adityatelange/hugo-PaperMod/wiki/FAQs#custom-head--footer
I did see this note when opening a PR, I'm going to explore this avenue. I do appreciate the desire not to bake in fetching things from 3rd party CDN servers to the greater theme.
Okay, I was able to get this working with the custom footer approach.. although I don't seem to have access to any values in .Page.Store.. will look for a different way of conditionally rendering it as I wouldn't want to pull this script from the CDN on Markdown pages that do not use Mermaid.js
Hi,
Hugo's documentation supports Mermaid Diagrams via Mermaid JS and I was hoping we could get this added to the theme.
I was able to get this working locally with the diff below. I'm pretty new to Hugo, so I'm unsure if this is the best place to add this functionality (specifically within single.html).
I'll create a PR shortly for review, would appreciate any feedback or guidance!
The text was updated successfully, but these errors were encountered: