feat(CDN): replace CDN config with CDN data file (#353)

This commit is contained in:
Dillon
2020-05-13 19:29:37 +08:00
committed by GitHub
parent 762a7e538d
commit 39159a9a6d
7 changed files with 159 additions and 279 deletions

View File

@@ -13,7 +13,16 @@
{{- $params := .Params | merge .Site.Params.page -}}
{{- if eq hugo.Environment "production" -}}
{{- .Scratch.Set "cdn" .Site.Params.cdn -}}
{{- $cdn := .Site.Params.cdn -}}
{{- with $cdn.data -}}
{{- $cdnData := printf "data/cdn/%s" . | resources.Get | transform.Unmarshal -}}
{{- $cdn = dict "simpleIconsPrefix" $cdnData.prefix.simpleIcons -}}
{{- $prefix := $cdnData.prefix.libFiles | default "" -}}
{{- range $key, $value := $cdnData.libFiles -}}
{{- $cdn = printf "%s%s" $prefix $value | dict $key | merge $cdn -}}
{{- end -}}
{{- end -}}
{{- .Scratch.Set "cdn" $cdn -}}
{{- .Scratch.Set "fingerprint" .Site.Params.fingerprint -}}
{{- .Scratch.Set "analytics" .Site.Params.analytics -}}
{{- .Scratch.Set "comment" $params.comment -}}