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

github.com/uPagge/uBlogger.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDillon ZENG <dillonzq@outlook.com>2019-11-23 20:10:17 +0300
committerDillon ZENG <dillonzq@outlook.com>2019-11-23 20:10:17 +0300
commit2578aba9ca8c4f45cbc6d379b57bca49ab9b9ea8 (patch)
treed4db15d0c07481304701867f85f4a9f02ebb0027 /layouts
parentb20fe1bb4f89c64b3bb82b31dbc0448ec565cd37 (diff)
feat(mermaid): improve mermaid style and render
Diffstat (limited to 'layouts')
-rw-r--r--layouts/partials/scripts.html12
-rw-r--r--layouts/shortcodes/align-center.html4
-rw-r--r--layouts/shortcodes/align-left.html4
-rw-r--r--layouts/shortcodes/align-right.html4
-rw-r--r--layouts/shortcodes/align.html5
-rw-r--r--layouts/shortcodes/countdown.html2
-rw-r--r--layouts/shortcodes/dev/echarts.html (renamed from layouts/shortcodes/echarts.html)6
-rw-r--r--layouts/shortcodes/diagram.html5
-rw-r--r--layouts/shortcodes/float-right.html4
-rw-r--r--layouts/shortcodes/float.html5
-rw-r--r--layouts/shortcodes/mermaid.html10
-rw-r--r--layouts/shortcodes/typeit.html2
12 files changed, 32 insertions, 31 deletions
diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html
index e35417b..0ecb50c 100644
--- a/layouts/partials/scripts.html
+++ b/layouts/partials/scripts.html
@@ -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 }}
diff --git a/layouts/shortcodes/align-center.html b/layouts/shortcodes/align-center.html
deleted file mode 100644
index eebd24c..0000000
--- a/layouts/shortcodes/align-center.html
+++ /dev/null
@@ -1,4 +0,0 @@
-{{ $_hugo_config := `{ "version": 1 }` -}}
-<div class="align-center">
- {{- .Inner -}}
-</div> \ No newline at end of file
diff --git a/layouts/shortcodes/align-left.html b/layouts/shortcodes/align-left.html
deleted file mode 100644
index b4cb051..0000000
--- a/layouts/shortcodes/align-left.html
+++ /dev/null
@@ -1,4 +0,0 @@
-{{ $_hugo_config := `{ "version": 1 }` -}}
-<div class="align-left">
- {{- .Inner -}}
-</div> \ No newline at end of file
diff --git a/layouts/shortcodes/align-right.html b/layouts/shortcodes/align-right.html
deleted file mode 100644
index 1886582..0000000
--- a/layouts/shortcodes/align-right.html
+++ /dev/null
@@ -1,4 +0,0 @@
-{{ $_hugo_config := `{ "version": 1 }` -}}
-<div class="align-right">
- {{- .Inner -}}
-</div> \ No newline at end of file
diff --git a/layouts/shortcodes/align.html b/layouts/shortcodes/align.html
new file mode 100644
index 0000000..51f2617
--- /dev/null
+++ b/layouts/shortcodes/align.html
@@ -0,0 +1,5 @@
+{{ $_hugo_config := `{ "version": 1 }` -}}
+<!-- [left, center, right] -->
+<div class={{ .Get 0 | printf "align-%s" }}>
+ {{- .Inner -}}
+</div> \ No newline at end of file
diff --git a/layouts/shortcodes/countdown.html b/layouts/shortcodes/countdown.html
index 6eb8e59..fd28e0c 100644
--- a/layouts/shortcodes/countdown.html
+++ b/layouts/shortcodes/countdown.html
@@ -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" -}}
diff --git a/layouts/shortcodes/echarts.html b/layouts/shortcodes/dev/echarts.html
index c3025a4..5b70bfa 100644
--- a/layouts/shortcodes/echarts.html
+++ b/layouts/shortcodes/dev/echarts.html
@@ -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> \ No newline at end of file
diff --git a/layouts/shortcodes/diagram.html b/layouts/shortcodes/diagram.html
deleted file mode 100644
index 1c30b9b..0000000
--- a/layouts/shortcodes/diagram.html
+++ /dev/null
@@ -1,5 +0,0 @@
-{{ $_hugo_config := `{ "version": 1 }` -}}
-{{ .Page.Scratch.Set "diagram" "true" }}
-<div class="mermaid">
- {{- .Inner -}}
-</div> \ No newline at end of file
diff --git a/layouts/shortcodes/float-right.html b/layouts/shortcodes/float-right.html
deleted file mode 100644
index 799c5f1..0000000
--- a/layouts/shortcodes/float-right.html
+++ /dev/null
@@ -1,4 +0,0 @@
-{{ $_hugo_config := `{ "version": 1 }` -}}
-<div class="float-right">
- {{- .Inner -}}
-</div> \ No newline at end of file
diff --git a/layouts/shortcodes/float.html b/layouts/shortcodes/float.html
new file mode 100644
index 0000000..f2a8140
--- /dev/null
+++ b/layouts/shortcodes/float.html
@@ -0,0 +1,5 @@
+{{ $_hugo_config := `{ "version": 1 }` -}}
+<!-- [left, right] -->
+<div class={{ .Get 0 | printf "float-%s" }}>
+ {{- .Inner -}}
+</div> \ No newline at end of file
diff --git a/layouts/shortcodes/mermaid.html b/layouts/shortcodes/mermaid.html
new file mode 100644
index 0000000..ebf406a
--- /dev/null
+++ b/layouts/shortcodes/mermaid.html
@@ -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> \ No newline at end of file
diff --git a/layouts/shortcodes/typeit.html b/layouts/shortcodes/typeit.html
index 6ad3545..9ecb84c 100644
--- a/layouts/shortcodes/typeit.html
+++ b/layouts/shortcodes/typeit.html
@@ -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 -->