🔥 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,17 +1,9 @@
{{/* Defind loading plugin scripts which only need in pages */}}
{{- $vendor := .vendor }}
{{- $router := .router }}
{{- $res := (index .res .index) }}
{{- $cssRes := $res.css }}
{{ if $cssRes }}
{{ range $cssRes }}
{{ $css := partial "_funs/get_res.html" (dict "res" . "vendor" $vendor "router" $router) }}
<link type="text/css" rel="stylesheet" href="{{ $css }}"/>
{{ end }}
{{ end }}
{{- $jsRes := $res.js }}
{{ range $jsRes }}
{{ $js := partial "_funs/get_res.html" (dict "res" . "vendor" $vendor "router" $router) }}
<script type="text/javascript" src="{{ $js }}"></script>
{{ if or .Params.math .Site.Params.math }}
{{ partial "_funs/get_plugin.html" (dict "ctx" . "class" "others" "plugin" "math.js") }}
{{ end }}
{{ if .Params.mermaid }}
{{ partial "_funs/get_plugin.html" (dict "ctx" . "class" "others" "plugin" "mermaid.js") }}
{{ end }}