perf: optimize mermaid script loading
This commit is contained in:
parent
6e00bc86da
commit
701a4b81d1
|
@ -72,4 +72,3 @@ editPage = false
|
||||||
highLight = true
|
highLight = true
|
||||||
kaTex = false
|
kaTex = false
|
||||||
collapsibleSidebar = false
|
collapsibleSidebar = false
|
||||||
mermaid = true
|
|
||||||
|
|
|
@ -11,14 +11,9 @@ menu:
|
||||||
parent: "prologue"
|
parent: "prologue"
|
||||||
weight: 110
|
weight: 110
|
||||||
toc: true
|
toc: true
|
||||||
|
mermaid: true
|
||||||
---
|
---
|
||||||
|
|
||||||
```js
|
|
||||||
function myFunction(p1, p2) {
|
|
||||||
return p1 * p2; // The function returns the product of p1 and p2
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Flowchart
|
## Flowchart
|
||||||
|
|
||||||
### Shortcode
|
### Shortcode
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
<script src="{{ $katexAutoRender.RelPermalink }}" onload="renderMathInElement(document.body);" defer></script>
|
<script src="{{ $katexAutoRender.RelPermalink }}" onload="renderMathInElement(document.body);" defer></script>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
<script src="{{ $js.RelPermalink }}" defer></script>
|
<script src="{{ $js.RelPermalink }}" defer></script>
|
||||||
{{ if .Site.Params.options.mermaid -}}
|
{{ with .Params.mermaid -}}
|
||||||
<script src="{{ $mermaid.RelPermalink }}" defer></script>
|
<script src="{{ $mermaid.RelPermalink }}" defer></script>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ if .Site.Params.options.flexSearch -}}
|
{{ if .Site.Params.options.flexSearch -}}
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
<script src="{{ $katexAutoRender.RelPermalink }}" integrity="{{ $katexAutoRender.Data.Integrity }}" crossorigin="anonymous" defer></script>
|
<script src="{{ $katexAutoRender.RelPermalink }}" integrity="{{ $katexAutoRender.Data.Integrity }}" crossorigin="anonymous" defer></script>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}" crossorigin="anonymous" defer></script>
|
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}" crossorigin="anonymous" defer></script>
|
||||||
{{ if .Site.Params.options.mermaid -}}
|
{{ with .Params.mermaid -}}
|
||||||
<script src="{{ $mermaid.RelPermalink }}" integrity="{{ $mermaid.Data.Integrity }}" crossorigin="anonymous" defer></script>
|
<script src="{{ $mermaid.RelPermalink }}" integrity="{{ $mermaid.Data.Integrity }}" crossorigin="anonymous" defer></script>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ if .Site.Params.options.flexSearch -}}
|
{{ if .Site.Params.options.flexSearch -}}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{{ if .Site.Params.options.mermaid -}}
|
{{ if .Page.Params.mermaid -}}
|
||||||
<div class="mermaid{{ with .Get "class" }} {{ . }}{{ end }}">
|
<div class="mermaid{{ with .Get "class" }} {{ . }}{{ end }}">
|
||||||
{{ $data := replaceRE "(^\\s+```)" "" .Inner -}}
|
{{ $data := replaceRE "(^\\s+```)" "" .Inner -}}
|
||||||
{{ replaceRE "(```\\s+$)" "" $data -}}
|
{{ replaceRE "(```\\s+$)" "" $data -}}
|
||||||
</div>
|
</div>
|
||||||
{{ else -}}
|
{{ 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 -}}
|
{{ end -}}
|
||||||
|
|
Loading…
Reference in New Issue