mirror of
https://github.com/dillonzq/LoveIt.git
synced 2024-11-14 02:46:16 +01:00
feat(assets): add SRI config for stylesheet and script
This commit is contained in:
parent
ac08e0776e
commit
924692a07e
24 changed files with 62 additions and 32 deletions
|
@ -208,7 +208,7 @@ enableEmoji = true
|
|||
# Disqus Comment Config (https://disqus.com/)
|
||||
[languages.en.params.comment.disqus]
|
||||
# Disqus shortname to use Disqus in posts
|
||||
shortname = "dillonzq"
|
||||
shortname = ""
|
||||
# Gittalk Comment Config (https://github.com/gitalk/gitalk)
|
||||
[languages.en.params.comment.gitalk]
|
||||
owner = ""
|
||||
|
@ -423,7 +423,7 @@ enableEmoji = true
|
|||
# Disqus 评论系统设置 (https://disqus.com/)
|
||||
[languages.zh-CN.params.comment.disqus]
|
||||
# Disqus 的用户名,用来在文章中启用 Disqus 评论系统
|
||||
shortname = "dillonzq"
|
||||
shortname = ""
|
||||
# Gittalk 评论系统设置 (https://github.com/gitalk/gitalk)
|
||||
[languages.zh-CN.params.comment.gitalk]
|
||||
owner = ""
|
||||
|
@ -638,7 +638,7 @@ enableEmoji = true
|
|||
# Disqus Comment Config (https://disqus.com/)
|
||||
[languages.fr.params.comment.disqus]
|
||||
# Disqus shortname to use Disqus in posts
|
||||
shortname = "dillonzq"
|
||||
shortname = ""
|
||||
# Gittalk Comment Config (https://github.com/gitalk/gitalk)
|
||||
[languages.fr.params.comment.gitalk]
|
||||
owner = ""
|
||||
|
@ -674,6 +674,9 @@ enableEmoji = true
|
|||
# public git repo url only then enableGitInfo is true
|
||||
# 公共 git 仓库路径,仅在 enableGitInfo 设为 true 时有效
|
||||
gitRepo = "https://github.com/dillonzq/LoveIt"
|
||||
# which hash function used for SRI, when empty, no SRI is used ("sha256", "sha384", "sha512", "md5")
|
||||
# 哪种哈希函数用来 SRI, 为空时表示不使用 SRI ("sha256", "sha384", "sha512", "md5")
|
||||
fingerprint = ""
|
||||
# Header info
|
||||
# 页面头部导航栏信息
|
||||
[params.header]
|
||||
|
|
|
@ -193,6 +193,9 @@ Note that some of these parameters are explained in details in other sections of
|
|||
defaultTheme = "auto"
|
||||
# public git repo url only then enableGitInfo is true
|
||||
gitRepo = ""
|
||||
# LoveIt :(fas fa-greater-than-equal): :(far fa-file-archive): v0.1.1
|
||||
# which hash function used for SRI, when empty, no SRI is used ("sha256", "sha384", "sha512", "md5")
|
||||
fingerprint = ""
|
||||
# Header info
|
||||
[params.header]
|
||||
# desktop header mode ("fixed", "normal", "auto")
|
||||
|
|
|
@ -198,6 +198,9 @@ Note that some of these parameters are explained in details in other sections of
|
|||
defaultTheme = "auto"
|
||||
# public git repo url only then enableGitInfo is true
|
||||
gitRepo = ""
|
||||
# LoveIt :(fas fa-greater-than-equal): :(far fa-file-archive): v0.1.1
|
||||
# which hash function used for SRI, when empty, no SRI is used ("sha256", "sha384", "sha512", "md5")
|
||||
fingerprint = ""
|
||||
# Header info
|
||||
[params.header]
|
||||
# desktop header mode ("fixed", "normal", "auto")
|
||||
|
|
|
@ -193,6 +193,9 @@ hugo
|
|||
defaultTheme = "auto"
|
||||
# 公共 git 仓库路径,仅在 enableGitInfo 设为 true 时有效
|
||||
gitRepo = ""
|
||||
# LoveIt :(fas fa-greater-than-equal): :(far fa-file-archive): v0.1.1
|
||||
# 哪种哈希函数用来 SRI, 为空时表示不使用 SRI ("sha256", "sha384", "sha512", "md5")
|
||||
fingerprint = ""
|
||||
# 页面头部导航栏信息
|
||||
[params.header]
|
||||
# 桌面端导航栏模式 ("fixed", "normal", "auto")
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
{{- if eq hugo.Environment "production" -}}
|
||||
{{- $scratch.Set "production" true -}}
|
||||
{{- $scratch.Set "CDN" .Site.Params.cdn -}}
|
||||
{{- $scratch.Set "fingerprint" .Site.Params.fingerprint -}}
|
||||
{{- end -}}
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
{{- /* Title */ -}}
|
||||
<h1 class="single-title" itemprop="name headline">
|
||||
<a href="{{ .Permalink }}">{{ .Title }}</a>
|
||||
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
|
||||
</h1>
|
||||
|
||||
{{- /* Meta */ -}}
|
||||
|
@ -55,7 +55,7 @@
|
|||
|
||||
{{- /* Footer */ -}}
|
||||
<div class="post-footer">
|
||||
<a href="{{ .Permalink }}">{{ T "readMore" }}</a>
|
||||
<a href="{{ .RelPermalink }}">{{ T "readMore" }}</a>
|
||||
{{- with .Params.tags -}}
|
||||
<div class="post-tags">
|
||||
{{- range . -}}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -23,20 +23,20 @@
|
|||
<div class="card-item">
|
||||
<div class="card-item-wrapper">
|
||||
<h3 class="card-item-title">
|
||||
<a href="{{ .Permalink }}">
|
||||
<a href="{{ .RelPermalink }}">
|
||||
<i class="far fa-folder fa-fw"></i> {{ $term | humanize}}
|
||||
</a>
|
||||
</h3>
|
||||
{{- range first 5 $pages -}}
|
||||
<article class="archive-item">
|
||||
<a href="{{ .Permalink }}" class="archive-item-link">
|
||||
<a href="{{ .RelPermalink }}" class="archive-item-link">
|
||||
{{- .Title -}}
|
||||
</a>
|
||||
</article>
|
||||
{{- end -}}
|
||||
{{- if gt (len $pages) 5 -}}
|
||||
<span class="more-post">
|
||||
<a href="{{ .Permalink }}" class="more-single-link">{{ T "more" }} >></a>
|
||||
<a href="{{ .RelPermalink }}" class="more-single-link">{{ T "more" }} >></a>
|
||||
</span>
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
@ -49,7 +49,7 @@
|
|||
{{- else if eq $taxonomies "tags" -}}
|
||||
<div class="tag-cloud-tags">
|
||||
{{- range $.Site.Taxonomies.tags.ByCount -}}
|
||||
<a href="{{ .Page.Permalink }}"> {{ .Page.Title }} <small>({{ .Count }})</small></a>
|
||||
<a href="{{ .Page.RelPermalink }}"> {{ .Page.Title }} <small>({{ .Count }})</small></a>
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "loveit-src",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"description": "LoveIt theme source file",
|
||||
"main": "index.js",
|
||||
"dependencies": {},
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{"Target":"css/style.min.8596c27951d415c1b2ad9aee1d642e8057049327eca5ce9e397bdd27d84ca62a.css","MediaType":"text/css","Data":{"Integrity":"sha256-hZbCeVHUFcGyrZruHWQugFcEkyfspc6eOXvdJ9hMpio="}}
|
|
@ -0,0 +1 @@
|
|||
{"Target":"css/style.min.css","MediaType":"text/css","Data":{}}
|
|
@ -0,0 +1 @@
|
|||
{"Target":"lib/aplayer/dark.css","MediaType":"text/css","Data":{}}
|
|
@ -1 +0,0 @@
|
|||
{"Target":"lib/aplayer/dark.cf3d10211c52ef53113d7dc3ab708c366141ee4459043a50b02215bc8a2ef76a.css","MediaType":"text/css","Data":{"Integrity":"sha256-zz0QIRxS71MRPX3Dq3CMNmFB7kRZBDpQsCIVvIou92o="}}
|
|
@ -0,0 +1 @@
|
|||
{"Target":"lib/mermaid/mermaid.css","MediaType":"text/css","Data":{}}
|
|
@ -1 +0,0 @@
|
|||
{"Target":"lib/mermaid/mermaid.828bd139deac55c048b4d9ed77d849196aada4a0ea2268d7c59946e8d71665b7.css","MediaType":"text/css","Data":{"Integrity":"sha256-govROd6sVcBItNntd9hJGWqtpKDqImjXxZlG6NcWZbc="}}
|
Loading…
Reference in a new issue