🔥 Refactor struct & code for loading 3rd scripts.

This commit is contained in:
凡梦星尘
2022-10-27 15:57:42 +08:00
parent 9160a33053
commit 0d1b00f7b0
21 changed files with 302 additions and 210 deletions

View File

@@ -1,5 +1,4 @@
<script class="next-config" data-name="page" type="application/json">
{{- dict
{{- $pageCfg := dict
"isHome" .IsHome
"isPage" .IsPage
"comments" (.Params.comments | default .Site.Params.comments.enable)
@@ -7,4 +6,27 @@
"path" (.Page.Permalink | path.Base)
"title" .Page.Title
-}}
</script>
{{/* Append mermaid plugin */}}
{{ if .Params.mermaid }}
{{ $mermaid := dict
"js" .Site.Data.resources.plugins.mermaid.js
}}
{{ $pageCfg = merge $pageCfg (dict "mermaid" $mermaid) }}
{{ end }}
{{/* Append math render plugin */}}
{{ with or .Params.math .Site.Params.math }}
{{ $math := dict
"render" .
"js" (index $.Site.Data.resources.plugins .).js
}}
{{ if eq . "katex" }}
{{ $math = merge $math ( dict "css" $.Site.Data.resources.plugins.katex.css ) }}
{{ end }}
{{ $pageCfg = merge $pageCfg (dict "math" $math) }}
{{ end }}
<script class="next-config" data-name="page" type="application/json">{{- $pageCfg -}}</script>