diff options
author | peaceiris <30958501+peaceiris@users.noreply.github.com> | 2020-02-03 09:44:05 +0300 |
---|---|---|
committer | peaceiris <30958501+peaceiris@users.noreply.github.com> | 2020-02-03 09:44:05 +0300 |
commit | d234a9024fb65267d918c09651b301c6d8c576de (patch) | |
tree | dadb8a36b17420f51b8adbf2d7ff2fadb56e4325 /layouts | |
parent | 17d410aef04ac4699690f797813903638e645f41 (diff) |
feat: Add mermaid
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/baseof.html | 1 | ||||
-rw-r--r-- | layouts/partials/content.html | 3 | ||||
-rw-r--r-- | layouts/partials/mermaid.html | 22 |
3 files changed, 26 insertions, 0 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 52312518..ed710ecd 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -15,5 +15,6 @@ </section> {{ partial "footer" . }} {{ partial "mathjax" . }} + {{ partial "mermaid" . }} </body> </html> diff --git a/layouts/partials/content.html b/layouts/partials/content.html index 0e301fd4..860796a1 100644 --- a/layouts/partials/content.html +++ b/layouts/partials/content.html @@ -10,6 +10,9 @@ {{ $content = $content | replaceRE "<h5 " "<h5 class=\"title is-5\" " }} {{ $content = $content | replaceRE "<h6 " "<h6 class=\"title is-6\" " }} +<!-- mermaid --> +{{ $content = $content | replaceRE "<code class=\"language-mermaid\" data-lang=\"mermaid\">" "<div class=\"mermaid\">" }} + <section class="section"> {{ partial "toc" . }} {{ $content | safeHTML }} diff --git a/layouts/partials/mermaid.html b/layouts/partials/mermaid.html new file mode 100644 index 00000000..47070de4 --- /dev/null +++ b/layouts/partials/mermaid.html @@ -0,0 +1,22 @@ +{{ $hasMermaid := findRE "<code class=\"language-mermaid\" data-lang=\"mermaid\">" .Content }} + +{{ with $hasMermaid }} + + {{ $js := resources.Get "js/mermaid-v8.4.6.min.js" }} + {{ $secureJS := $js | resources.Fingerprint "sha512" }} + <script src="{{ $secureJS.Permalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script> + <script> + var config = { + startOnLoad: true, + flowchart: { + useMaxWidth: true, + htmlLabels: true, + curve: "cardinal", + }, + theme: "neutral", + securityLevel: "strict", + }; + + mermaid.initialize(config); + </script> +{{ end }} |