feat(assets): add SRI config for stylesheet and script
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
{{- end -}}
|
||||
|
||||
{{- /* lightgallery.js */ -}}
|
||||
{{- if ne .Page.Site.Params.page.lightgallery false | and (ne .Page.Params.lightgallery false) -}}
|
||||
{{- if ne .Site.Params.page.lightgallery false | and (ne .Params.lightgallery false) -}}
|
||||
{{- with $CDN.lightgalleryCSS -}}
|
||||
{{- slice . | $scratch.Add "linkCDN" -}}
|
||||
{{- else -}}
|
||||
@@ -222,8 +222,8 @@
|
||||
{{- else if not (strings.HasSuffix . ".min.css") -}}
|
||||
{{- $res = minify $res -}}
|
||||
{{- end -}}
|
||||
{{- $res = $res | resources.Fingerprint "sha256" -}}
|
||||
<link rel="stylesheet" href="{{ $res.RelPermalink }}" integrity="{{ $res.Data.Integrity }}">
|
||||
{{- $stylesheet := (dict "resource" $res "fingerprint" ($scratch.Get "fingerprint")) -}}
|
||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- range $scratch.Get "scriptCDN" -}}
|
||||
@@ -234,8 +234,8 @@
|
||||
{{- if not (strings.HasSuffix . ".min.js") -}}
|
||||
{{- $res = minify $res -}}
|
||||
{{- end -}}
|
||||
{{- $res = $res | resources.Fingerprint "sha256" -}}
|
||||
<script src="{{ $res.RelPermalink }}" integrity="{{ $res.Data.Integrity }}"></script>
|
||||
{{- $script := (dict "resource" $res "fingerprint" ($scratch.Get "fingerprint")) -}}
|
||||
{{- partial "plugin/script.html" $script -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Google analytics async */ -}}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
{{- /* Disqus Comment System */ -}}
|
||||
{{- with .Site.Params.comment.disqus.shortname -}}
|
||||
<div id="disqus_thread"></div>
|
||||
{{- $script := printf `<script src="https://%s.disqus.com/embed.js"></script>` . -}}
|
||||
{{- $script := printf `<script defer src="https://%s.disqus.com/embed.js"></script>` . -}}
|
||||
{{- slice $script | $scratch.Add "scriptCDN" -}}
|
||||
<noscript>
|
||||
Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
|
||||
|
||||
@@ -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 -}}
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
{{- range $.Site.Languages -}}
|
||||
{{- if eq $translation.Lang .Lang -}}
|
||||
{{- if eq $.Page.Lang .Lang -}}
|
||||
<option value="{{ $translation.Permalink }}" selected>{{ .LanguageName }}</option>
|
||||
<option value="{{ $translation.RelPermalink }}" selected>{{ .LanguageName }}</option>
|
||||
{{- else -}}
|
||||
<option value="{{ $translation.Permalink }}">{{ .LanguageName }}</option>
|
||||
<option value="{{ $translation.RelPermalink }}">{{ .LanguageName }}</option>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -68,9 +68,9 @@
|
||||
{{- range $.Site.Languages -}}
|
||||
{{- if eq $translation.Lang .Lang -}}
|
||||
{{- if eq $.Page.Lang .Lang -}}
|
||||
<option value="{{ $translation.Permalink }}" selected>{{ .LanguageName }}</option>
|
||||
<option value="{{ $translation.RelPermalink }}" selected>{{ .LanguageName }}</option>
|
||||
{{- else -}}
|
||||
<option value="{{ $translation.Permalink }}">{{ .LanguageName }}</option>
|
||||
<option value="{{ $translation.RelPermalink }}">{{ .LanguageName }}</option>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
7
layouts/partials/plugin/script.html
Normal file
7
layouts/partials/plugin/script.html
Normal file
@@ -0,0 +1,7 @@
|
||||
{{- $res := .resource -}}
|
||||
{{- with .fingerprint -}}
|
||||
{{- $res = $res | resources.Fingerprint . -}}
|
||||
<script src="{{ $res.RelPermalink }}" integrity="{{ $res.Data.Integrity }}"></script>
|
||||
{{- else -}}
|
||||
<script src="{{ $res.RelPermalink }}"></script>
|
||||
{{- end -}}
|
||||
7
layouts/partials/plugin/stylesheet.html
Normal file
7
layouts/partials/plugin/stylesheet.html
Normal file
@@ -0,0 +1,7 @@
|
||||
{{- $res := .resource -}}
|
||||
{{- with .fingerprint -}}
|
||||
{{- $res = $res | resources.Fingerprint . -}}
|
||||
<link rel="stylesheet" href="{{ $res.RelPermalink }}" integrity="{{ $res.Data.Integrity }}">
|
||||
{{- else -}}
|
||||
<link rel="stylesheet" href="{{ $res.RelPermalink }}">
|
||||
{{- end -}}
|
||||
@@ -26,7 +26,7 @@
|
||||
{{- if ne .Site.Params.page.linkToMarkdown false | and (ne .Params.linkToMarkdown false) -}}
|
||||
{{- with .OutputFormats.Get "markdown" -}}
|
||||
<span>
|
||||
<a class="link-to-markdown" href="{{ .Permalink }}" target="_blank">
|
||||
<a class="link-to-markdown" href="{{ .RelPermalink }}" target="_blank">
|
||||
{{- T "seeMarkdown" -}}
|
||||
</a>
|
||||
</span>
|
||||
@@ -60,10 +60,10 @@
|
||||
|
||||
<div class="post-nav">
|
||||
{{- if .PrevInSection -}}
|
||||
<a href="{{ .PrevInSection.Permalink }}" class="prev" rel="prev" title="{{ .PrevInSection.Title }}"><i class="fas fa-angle-left fa-fw"></i>{{ .PrevInSection.Title }}</a>
|
||||
<a href="{{ .PrevInSection.RelPermalink }}" class="prev" rel="prev" title="{{ .PrevInSection.Title }}"><i class="fas fa-angle-left fa-fw"></i>{{ .PrevInSection.Title }}</a>
|
||||
{{- end -}}
|
||||
{{ if .NextInSection }}
|
||||
<a href="{{ .NextInSection.Permalink }}" class="next" rel="next" title="{{ .NextInSection.Title }}">{{ .NextInSection.Title }}<i class="fas fa-angle-right fa-fw"></i></a>
|
||||
<a href="{{ .NextInSection.RelPermalink }}" class="next" rel="next" title="{{ .NextInSection.Title }}">{{ .NextInSection.Title }}<i class="fas fa-angle-right fa-fw"></i></a>
|
||||
{{- end -}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user