feat(assets): add SRI config for stylesheet and script

This commit is contained in:
Dillon
2020-03-09 20:25:55 +08:00
parent ac08e0776e
commit 924692a07e
24 changed files with 62 additions and 32 deletions

View File

@@ -25,16 +25,18 @@
{{- with $CDN.fontawesomeFreeCSS -}}
{{- . | safeHTML -}}
{{- else -}}
{{- $res := resources.Get "lib/fontawesome-free/all.min.css" | resources.Fingerprint "sha256" -}}
<link rel="stylesheet" href="{{ $res.RelPermalink }}" integrity="{{ $res.Data.Integrity }}">
{{- $res := resources.Get "lib/fontawesome-free/all.min.css" -}}
{{- $stylesheet := (dict "resource" $res "fingerprint" ($scratch.Get "fingerprint")) -}}
{{- partial "plugin/stylesheet.html" $stylesheet -}}
{{- end -}}
{{- /* Animate.css */ -}}
{{- with $CDN.animateCSS -}}
{{- . | safeHTML -}}
{{- else -}}
{{ $res := resources.Get "lib/animate/animate.min.css" | resources.Fingerprint "sha256" -}}
<link rel="stylesheet" href="{{ $res.RelPermalink }}" integrity="{{ $res.Data.Integrity }}">
{{- $res := resources.Get "lib/fontawesome-free/all.min.css" -}}
{{- $stylesheet := (dict "resource" $res "fingerprint" ($scratch.Get "fingerprint")) -}}
{{- partial "plugin/stylesheet.html" $stylesheet -}}
{{- end -}}
{{- /* style.min.css */ -}}
@@ -43,5 +45,6 @@
{{- $options = dict "includePaths" (slice "config/css") | merge $options -}}
{{- $options = dict "outputStyle" "compressed" | merge $options -}}
{{- $options = dict "enableSourceMap" true | merge $options -}}
{{- $res = resources.ExecuteAsTemplate "style.scss" . $res | toCSS $options | resources.Fingerprint "sha256" -}}
<link rel="stylesheet" href="{{ $res.RelPermalink }}" integrity="{{ $res.Data.Integrity }}">
{{- $res = resources.ExecuteAsTemplate "style.scss" . $res | toCSS $options -}}
{{- $stylesheet := (dict "resource" $res "fingerprint" ($scratch.Get "fingerprint")) -}}
{{- partial "plugin/stylesheet.html" $stylesheet -}}