diff options
author | ammo0110 <35888494+ammo0110@users.noreply.github.com> | 2019-08-30 13:25:27 +0300 |
---|---|---|
committer | Munif Tanjim <muniftanjim@gmail.com> | 2019-08-30 13:25:27 +0300 |
commit | 1da804a78a39e951dd5febb5b24e83b2927579e0 (patch) | |
tree | 2975cfc31eb1816f891a5aac78a1506191120610 | |
parent | 4eb4160c94dd2f85fc8a10fb7d220127252a11d8 (diff) |
add [feature]: mermaid support
resolves #231
-rw-r--r-- | data/config/default/mermaid.json | 6 | ||||
-rw-r--r-- | layouts/partials/footer/mermaid.html | 14 | ||||
-rw-r--r-- | layouts/partials/footer/scripts.html | 1 | ||||
-rw-r--r-- | layouts/shortcodes/mermaid.html | 7 |
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 -}} |