feat(mermaid): improve mermaid style and render
This commit is contained in:
@@ -54,7 +54,8 @@
|
||||
{{ $res := resources.Get "js/lib/mermaid/mermaid.min.js" | resources.Minify }}
|
||||
{{ $mermaid = printf "<script src=\"%s\"></script>" $res.RelPermalink }}
|
||||
{{ end }}
|
||||
{{ $mermaid = delimit (slice $mermaid "<script>mermaid.initialize({startOnLoad: true, theme: null,});</script>") "" }}
|
||||
{{ $mermaidInit := "<script>mermaid.initialize({startOnLoad: false, theme: null});</script>" }}
|
||||
{{ $mermaid = delimit (slice $mermaid $mermaidInit) "" }}
|
||||
<!-- ECharts https://github.com/apache/incubator-echarts -->
|
||||
{{ $echarts_js := "" }}
|
||||
{{ if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.echarts_js }}
|
||||
@@ -117,21 +118,22 @@
|
||||
{{ $smooth_scroll | safeHTML }}
|
||||
|
||||
{{ if .IsPage }}
|
||||
{{/* dev feature */}}
|
||||
{{/* dev feature */}}
|
||||
{{ if .Params.dev }}
|
||||
{{ with .Scratch.Get "echartsMap" }}
|
||||
{{ $echarts | safeHTML }}
|
||||
{{ $echartsMap := . }}
|
||||
<script>window.echartsMap = {
|
||||
{{ range $key, $var := $echartsMap }}
|
||||
{{ range $key, $var := . }}
|
||||
{{ $key }}: {{ $var | safeJS }},
|
||||
{{ end }}
|
||||
};window.echartsArr=[];</script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{/* dev feature */}}
|
||||
|
||||
{{ if .Scratch.Get "diagram" }}
|
||||
{{ with .Scratch.Get "mermaidMap" }}
|
||||
{{ $mermaid | safeHTML }}
|
||||
<script>window.mermaidMap = {{ . | jsonify | safeJS }};</script>
|
||||
{{ end }}
|
||||
|
||||
{{ if or .Params.math .Site.Params.math }}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
{{ $_hugo_config := `{ "version": 1 }` -}}
|
||||
<div class="align-left">
|
||||
{{- .Inner -}}
|
||||
</div>
|
||||
@@ -1,4 +0,0 @@
|
||||
{{ $_hugo_config := `{ "version": 1 }` -}}
|
||||
<div class="align-right">
|
||||
{{- .Inner -}}
|
||||
</div>
|
||||
5
layouts/shortcodes/align.html
Normal file
5
layouts/shortcodes/align.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{ $_hugo_config := `{ "version": 1 }` -}}
|
||||
<!-- [left, center, right] -->
|
||||
<div class={{ .Get 0 | printf "align-%s" }}>
|
||||
{{- .Inner -}}
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
{{ if .Get "date" -}}
|
||||
{{ $date := .Get "date" }}
|
||||
{{ $id := delimit (split (md5 $date) "" | shuffle) "" | printf "cd-%s" -}}
|
||||
{{ $id := delimit (split (md5 $date) "" | shuffle) "" | printf "countdown-%s" -}}
|
||||
{{ $defaultPattern := printf "%%D %s %%H %s %%M %s %%S %s" (T "day") (T "hour") (T "minute") (T "second") }}
|
||||
{{ $new := dict $id (dict "date" $date "pattern" (.Get "pattern" | default $defaultPattern)) }}
|
||||
{{ with .Page.Scratch.Get "countdownMap" -}}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<!-- shuffle md5 as id -->
|
||||
{{ $id := delimit (split (md5 .Inner) "" | shuffle) "" | printf "ec-%s" -}}
|
||||
{{ $id := delimit (split (md5 .Inner) "" | shuffle) "" | printf "echarts-%s" -}}
|
||||
{{ $echartsMap := .Page.Scratch.Get "echartsMap" -}}
|
||||
{{ if $echartsMap -}}
|
||||
{{ $echartsMap = dict $id .Inner | merge $echartsMap -}}
|
||||
{{ $echartsMap = .Inner | printf "{%s}" | dict $id | merge $echartsMap -}}
|
||||
{{ else -}}
|
||||
{{ $echartsMap = dict $id .Inner -}}
|
||||
{{ $echartsMap = .Inner | printf "{%s}" | dict $id -}}
|
||||
{{ end -}}
|
||||
{{ .Page.Scratch.Set "echartsMap" $echartsMap -}}
|
||||
<div class="echarts" id="{{ $id }}"></div>
|
||||
@@ -1,5 +0,0 @@
|
||||
{{ $_hugo_config := `{ "version": 1 }` -}}
|
||||
{{ .Page.Scratch.Set "diagram" "true" }}
|
||||
<div class="mermaid">
|
||||
{{- .Inner -}}
|
||||
</div>
|
||||
@@ -1,4 +0,0 @@
|
||||
{{ $_hugo_config := `{ "version": 1 }` -}}
|
||||
<div class="float-right">
|
||||
{{- .Inner -}}
|
||||
</div>
|
||||
@@ -1,4 +1,5 @@
|
||||
{{ $_hugo_config := `{ "version": 1 }` -}}
|
||||
<div class="align-center">
|
||||
<!-- [left, right] -->
|
||||
<div class={{ .Get 0 | printf "float-%s" }}>
|
||||
{{- .Inner -}}
|
||||
</div>
|
||||
10
layouts/shortcodes/mermaid.html
Normal file
10
layouts/shortcodes/mermaid.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!-- shuffle md5 as id -->
|
||||
{{ $id := delimit (split (md5 .Inner) "" | shuffle) "" | printf "mermaid-%s" -}}
|
||||
{{ $mermaidMap := .Page.Scratch.Get "mermaidMap" -}}
|
||||
{{ if $mermaidMap -}}
|
||||
{{ $mermaidMap = trim .Inner "\n" | dict $id | merge $mermaidMap -}}
|
||||
{{ else -}}
|
||||
{{ $mermaidMap = trim .Inner "\n" | dict $id -}}
|
||||
{{ end -}}
|
||||
{{ .Page.Scratch.Set "mermaidMap" $mermaidMap -}}
|
||||
<div class="mermaid" id="{{ $id }}"></div>
|
||||
@@ -1,7 +1,7 @@
|
||||
<!-- only the trailing newline is retained -->
|
||||
{{ $content := replaceRE `(?s)^\n*(.*?)\n*$` "$1\n" .Inner }}
|
||||
<!-- shuffle md5 as id -->
|
||||
{{ $id := delimit (split (md5 $content) "" | shuffle) "" | printf "tp-%s" }}
|
||||
{{ $id := delimit (split (md5 $content) "" | shuffle) "" | printf "typeit-%s" }}
|
||||
|
||||
<div class={{ .Get "class" | default "typeit" }}>
|
||||
<!-- raw html content -->
|
||||
|
||||
Reference in New Issue
Block a user