perf: optimize mermaid script loading
This commit is contained in:
parent
6e00bc86da
commit
701a4b81d1
|
@ -72,4 +72,3 @@ editPage = false
|
|||
highLight = true
|
||||
kaTex = false
|
||||
collapsibleSidebar = false
|
||||
mermaid = true
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
<script src="{{ $katexAutoRender.RelPermalink }}" onload="renderMathInElement(document.body);" defer></script>
|
||||
{{ end -}}
|
||||
<script src="{{ $js.RelPermalink }}" defer></script>
|
||||
{{ if .Site.Params.options.mermaid -}}
|
||||
{{ with .Params.mermaid -}}
|
||||
<script src="{{ $mermaid.RelPermalink }}" defer></script>
|
||||
{{ end -}}
|
||||
{{ if .Site.Params.options.flexSearch -}}
|
||||
|
@ -90,7 +90,7 @@
|
|||
<script src="{{ $katexAutoRender.RelPermalink }}" integrity="{{ $katexAutoRender.Data.Integrity }}" crossorigin="anonymous" defer></script>
|
||||
{{ end -}}
|
||||
<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>
|
||||
{{ end -}}
|
||||
{{ 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 }}">
|
||||
{{ $data := replaceRE "(^\\s+```)" "" .Inner -}}
|
||||
{{ replaceRE "(```\\s+$)" "" $data -}}
|
||||
</div>
|
||||
{{ 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 -}}
|
||||
|
|
Loading…
Reference in New Issue