feat: add mermaidjs support

This commit is contained in:
TendTo 2022-08-25 01:26:55 +02:00
parent 3b825c1469
commit c6e3868249
No known key found for this signature in database
GPG key ID: F506E4A645EE7355
4 changed files with 18 additions and 0 deletions
README.md
layouts
_default
partials
shortcodes

View file

@ -15,6 +15,7 @@
* Table of contents
* Related content
* MathJax
* Mermaid
## Table of Contents
@ -151,6 +152,8 @@ googleAnalytics = "" # Enable Google Analytics by entering your tracking id
mathjax = true # Enable MathJax for all site pages
mathjaxPath = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js" # Specify MathJax path. Optional
mathjaxConfig = "TeX-AMS-MML_HTMLorMML" # Specify MathJax config. Optional
mermaid = true # Enable MathJax for all site pages
mermaidPath = "https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js" # Specify mermaid path. Optional
hideNoPostsWarning = false # Don't show no posts empty state warning in main page, if true
[Params.Entry]
@ -243,6 +246,7 @@ authorbox: true # Enable/disable Authorbox for specific page
toc: true # Enable/disable Table of Contents for specific page
tocOpen: true # Open Table of Contents block for specific page
mathjax: true # Enable/disable MathJax for specific page
mermaid: true # Enable/disable mermaid for specific page
related: true # Enable/disable Related content for specific page
meta:
- date

View file

@ -61,6 +61,7 @@
<script src="{{ "js/menu.js" | relURL }}"></script>
{{- end }}
{{- partial "mathjax.html" . -}}
{{- partial "mermaid.html" . -}}
{{- range .Site.Params.customJS }}
<script src="{{ . | relURL }}"></script>
{{- end }}

View file

@ -0,0 +1,3 @@
{{ if and .IsPage (eq (.Param "mermaid") true) }}
<script src={{ .Param "mermaidPath" | default "https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js" }} async></script>
{{ end }}

View file

@ -0,0 +1,10 @@
<div class="mermaid">
{{ if .Get "theme" }}
%%{init: {'theme': '{{.Get "theme"}}'}}%%
{{ else if .Get "configuration" }}
%%{{.Get "configuration"}}%%
{{ else }}
%%{init: {'theme': 'dark', 'themeVariables': { 'nodeBorder': '#9ccc6c'}}}%%
{{ end }}
{{.Inner}}
</div>