Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lxndrblz/anatole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Forman <58740+jforman@users.noreply.github.com>2022-05-21 12:47:30 +0300
committerGitHub <noreply@github.com>2022-05-21 12:47:30 +0300
commitd511a6f520bcc2ffab10ce009239904774ed6bb0 (patch)
tree1c4cc2dd38f38ef4e41495d8ec5a86748c41e1d7
parentc0c367c2de79783614b926a0661e287fc401af20 (diff)
feat: added mermaid support for displaying diagrams (#359)
* add mermaid support for making diagrams Co-authored-by: Jeffrey Forman <jforman@gmail.com> Co-authored-by: Alexander Bilz <mail@alexbilz.com>
-rw-r--r--README.md1
-rw-r--r--exampleSite/config/_default/params.toml3
-rw-r--r--layouts/_default/_markup/render-codeblock-mermaid.html4
-rw-r--r--layouts/_default/single.html6
-rw-r--r--layouts/partials/mermaid.html7
5 files changed, 21 insertions, 0 deletions
diff --git a/README.md b/README.md
index abed1c6..2811769 100644
--- a/README.md
+++ b/README.md
@@ -30,6 +30,7 @@ Anatole's aims to be minimalistic and sleek but still brings some great function
- Custom JavaScript and CSS (optional)
- Compliant to strict CSP
- Post Series
+- Mermaid diagram support (optional)
## Preview the Example Site
diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml
index fe21e86..3f7d450 100644
--- a/exampleSite/config/_default/params.toml
+++ b/exampleSite/config/_default/params.toml
@@ -73,3 +73,6 @@ url = "https://www.instagram.com/"
icon = "fas fa-envelope"
title = "e-mail"
url = "mailto:mail@example.com"
+
+[mermaid]
+# enable = true \ No newline at end of file
diff --git a/layouts/_default/_markup/render-codeblock-mermaid.html b/layouts/_default/_markup/render-codeblock-mermaid.html
new file mode 100644
index 0000000..5964155
--- /dev/null
+++ b/layouts/_default/_markup/render-codeblock-mermaid.html
@@ -0,0 +1,4 @@
+<div class="mermaid">
+ {{- .Inner | safeHTML }}
+</div>
+{{ .Page.Store.Set "hasMermaid" true }}
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index fbd73e8..f9ddd5a 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -68,6 +68,12 @@
{{- end -}}
+
+ {{- if (eq .Site.Params.mermaid.enable true) -}}
+ {{- partial "mermaid.html" . -}}
+
+
+ {{- end -}}
</div>
<div class="post__footer">
{{ with .Page.Params.Categories }}
diff --git a/layouts/partials/mermaid.html b/layouts/partials/mermaid.html
new file mode 100644
index 0000000..bcfd35d
--- /dev/null
+++ b/layouts/partials/mermaid.html
@@ -0,0 +1,7 @@
+{{ if .Page.Store.Get "hasMermaid" }}
+ <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
+ <script>
+ mermaid.initialize({ startOnLoad: true });
+ </script>
+
+{{ end }}