From 701a4b81d13f0d12a809dc0cde47683b54e555f1 Mon Sep 17 00:00:00 2001 From: Henk Verlinde Date: Fri, 2 Jul 2021 11:08:31 +0200 Subject: [PATCH] perf: optimize mermaid script loading --- config/_default/params.toml | 1 - content/docs/prologue/quick-start.md | 7 +------ layouts/partials/footer/script-footer.html | 4 ++-- layouts/shortcodes/mermaid.html | 4 ++-- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/config/_default/params.toml b/config/_default/params.toml index c571bf4..9601055 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -72,4 +72,3 @@ editPage = false highLight = true kaTex = false collapsibleSidebar = false - mermaid = true diff --git a/content/docs/prologue/quick-start.md b/content/docs/prologue/quick-start.md index 70de019..c95f282 100644 --- a/content/docs/prologue/quick-start.md +++ b/content/docs/prologue/quick-start.md @@ -11,14 +11,9 @@ menu: parent: "prologue" weight: 110 toc: true +mermaid: true --- -```js -function myFunction(p1, p2) { - return p1 * p2; // The function returns the product of p1 and p2 -} -``` - ## Flowchart ### Shortcode diff --git a/layouts/partials/footer/script-footer.html b/layouts/partials/footer/script-footer.html index c868c79..64ccf13 100644 --- a/layouts/partials/footer/script-footer.html +++ b/layouts/partials/footer/script-footer.html @@ -65,7 +65,7 @@ {{ end -}} - {{ if .Site.Params.options.mermaid -}} + {{ with .Params.mermaid -}} {{ end -}} {{ if .Site.Params.options.flexSearch -}} @@ -90,7 +90,7 @@ {{ end -}} - {{ if .Site.Params.options.mermaid -}} + {{ with .Params.mermaid -}} {{ end -}} {{ if .Site.Params.options.flexSearch -}} diff --git a/layouts/shortcodes/mermaid.html b/layouts/shortcodes/mermaid.html index ae18745..aeecad5 100644 --- a/layouts/shortcodes/mermaid.html +++ b/layouts/shortcodes/mermaid.html @@ -1,8 +1,8 @@ -{{ if .Site.Params.options.mermaid -}} +{{ if .Page.Params.mermaid -}}
{{ $data := replaceRE "(^\\s+```)" "" .Inner -}} {{ replaceRE "(```\\s+$)" "" $data -}}
{{ else -}} - {{ errorf "Failed to process mermaid shortcode(s). Set `mermaid = true` in `./config/_default/params.toml`." }} + {{ errorf "Failed to process mermaid shortcode: %s. Set mermaid to true in page front matter." .Position }} {{ end -}}