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

github.com/MunifTanjim/minimo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorammo0110 <35888494+ammo0110@users.noreply.github.com>2019-08-30 13:25:27 +0300
committerMunif Tanjim <muniftanjim@gmail.com>2019-08-30 13:25:27 +0300
commit1da804a78a39e951dd5febb5b24e83b2927579e0 (patch)
tree2975cfc31eb1816f891a5aac78a1506191120610
parent4eb4160c94dd2f85fc8a10fb7d220127252a11d8 (diff)
add [feature]: mermaid support
resolves #231
-rw-r--r--data/config/default/mermaid.json6
-rw-r--r--layouts/partials/footer/mermaid.html14
-rw-r--r--layouts/partials/footer/scripts.html1
-rw-r--r--layouts/shortcodes/mermaid.html7
4 files changed, 28 insertions, 0 deletions
diff --git a/data/config/default/mermaid.json b/data/config/default/mermaid.json
new file mode 100644
index 0000000..ce8719e
--- /dev/null
+++ b/data/config/default/mermaid.json
@@ -0,0 +1,6 @@
+{
+ "library": {
+ "path": "https://unpkg.com/mermaid/dist/mermaid.min.js"
+ },
+ "config": {}
+}
diff --git a/layouts/partials/footer/mermaid.html b/layouts/partials/footer/mermaid.html
new file mode 100644
index 0000000..f82f2c8
--- /dev/null
+++ b/layouts/partials/footer/mermaid.html
@@ -0,0 +1,14 @@
+{{- $defaultMermaid := .Site.Data.config.default.mermaid -}}
+{{- $mermaid := ( or .Site.Data.config.mermaid $defaultMermaid ) -}}
+
+{{- if eq .Params.mermaid true -}}
+
+<script src='{{- $mermaid.library.path -}}' />
+
+<script type='text/javascript'>
+ mermaid.initialize(
+ {{- $mermaid.config | jsonify | safeJS -}}
+ );
+</script>
+
+{{- end -}}
diff --git a/layouts/partials/footer/scripts.html b/layouts/partials/footer/scripts.html
index 3a0280b..497f73d 100644
--- a/layouts/partials/footer/scripts.html
+++ b/layouts/partials/footer/scripts.html
@@ -8,5 +8,6 @@
{{ partial "footer/mathjax" . }}
{{- partial "footer/katex" . -}}
+{{- partial "footer/mermaid" . -}}
{{ partial "footer/extra" . }}
diff --git a/layouts/shortcodes/mermaid.html b/layouts/shortcodes/mermaid.html
new file mode 100644
index 0000000..28094d8
--- /dev/null
+++ b/layouts/shortcodes/mermaid.html
@@ -0,0 +1,7 @@
+{{- if eq .Page.Params.mermaid true -}}
+
+<div class="mermaid">
+ {{ safeHTML .Inner }}
+</div>
+
+{{- end -}}