Skip to content

Commit 195c081

Browse files
committed
More template overrides for upgrade
1 parent 3881d14 commit 195c081

7 files changed

Lines changed: 448 additions & 1 deletion

File tree

config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enableRobotsTXT = true
2626
# Internal GA v4
2727
#googleAnalytics = ""
2828

29-
# Author moved to params.author (Site.Author deprecated in Hugo v0.124.0)
29+
# Author config for theme (accessed via .Site.Params.author.name)
3030
[params.author]
3131
name = "Eric Simmerman"
3232

layouts/_default/summary.html

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{{- $params := .Params | merge .Site.Params.page -}}
2+
3+
<article class="single summary" itemscope itemtype="http://schema.org/Article">
4+
{{- /* Featured image */ -}}
5+
{{- $image := $params.featuredimagepreview | default $params.featuredimage -}}
6+
{{- with .Resources.GetMatch "featured-image" -}}
7+
{{- $image = .RelPermalink -}}
8+
{{- end -}}
9+
{{- with .Resources.GetMatch "featured-image-preview" -}}
10+
{{- $image = .RelPermalink -}}
11+
{{- end -}}
12+
{{- with $image -}}
13+
<div class="featured-image-preview">
14+
<a href="{{ $.RelPermalink }}">
15+
{{- dict "Src" . "Title" $.Description "Resources" $.Resources | partial "plugin/img.html" -}}
16+
</a>
17+
</div>
18+
{{- end -}}
19+
20+
{{- /* Title */ -}}
21+
<h1 class="single-title" itemprop="name headline">
22+
<a href="{{ .RelPermalink }}">{{ .Title | emojify }}</a>
23+
</h1>
24+
25+
{{- /* Meta */ -}}
26+
<div class="post-meta">
27+
{{- $author := $params.author | default .Site.Params.author.name | default (T "author") -}}
28+
{{- $authorLink := $params.authorlink | default .Site.Params.author.link | default .Site.Home.RelPermalink -}}
29+
<span class="post-author">
30+
{{- $options := dict "Class" "author" "Destination" $authorLink "Title" "Author" "Rel" "author" "Icon" (dict "Class" "fas fa-user-circle fa-fw") "Content" $author -}}
31+
{{- partial "plugin/a.html" $options -}}
32+
</span>
33+
34+
{{- with .Site.Params.dateFormat | default "2006-01-02" | .PublishDate.Format -}}
35+
&nbsp;<span class="post-publish">
36+
{{- printf `<time datetime="%v">%v</time>` . . | dict "Date" | T "publishedOnDate" | safeHTML -}}
37+
</span>
38+
{{- end -}}
39+
40+
{{- $categories := slice -}}
41+
{{- range .Params.categories -}}
42+
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
43+
{{- $categories = $categories | append (printf `<a href="%v"><i class="far fa-folder fa-fw" aria-hidden="true"></i>%v</a>` $category.RelPermalink $category.Title) -}}
44+
{{- end -}}
45+
{{- with delimit $categories "&nbsp;" -}}
46+
&nbsp;<span class="post-category">
47+
{{- dict "Categories" . | T "includedInCategories" | safeHTML -}}
48+
</span>
49+
{{- end -}}
50+
</div>
51+
52+
{{- /* Summary content */ -}}
53+
<div class="content">
54+
{{- with .Summary -}}
55+
{{- dict "Content" . "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
56+
{{- else -}}
57+
{{- .Description | safeHTML -}}
58+
{{- end -}}
59+
</div>
60+
61+
{{- /* Footer */ -}}
62+
<div class="post-footer">
63+
<a href="{{ .RelPermalink }}">{{ T "readMore" }}</a>
64+
{{- with .Params.tags -}}
65+
<div class="post-tags">
66+
<i class="fas fa-tags fa-fw" aria-hidden="true"></i>&nbsp;
67+
{{- range $index, $value := . -}}
68+
{{- if gt $index 0 }},&nbsp;{{ end -}}
69+
{{- $tag := partialCached "function/path.html" $value $value | printf "/tags/%v" | $.Site.GetPage -}}
70+
<a href="{{ $tag.RelPermalink }}">{{ $tag.Title }}</a>
71+
{{- end -}}
72+
</div>
73+
{{- end -}}
74+
</div>
75+
</article>

layouts/partials/footer.html

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{{- if ne .Site.Params.footer.enable false -}}
2+
<footer class="footer">
3+
<div class="footer-container">
4+
{{- /* Custom Content */ -}}
5+
{{- with .Site.Params.footer.custom -}}
6+
<div class="footer-line">
7+
{{- safeHTML . -}}
8+
</div>
9+
{{- end -}}
10+
11+
{{- /* Hugo and LoveIt */ -}}
12+
{{- if ne .Site.Params.footer.hugo false -}}
13+
<div class="footer-line">
14+
{{- $hugo := printf `<a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo %v">Hugo</a>` hugo.Version -}}
15+
{{- $theme := .Scratch.Get "version" | printf `<a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt %v"><i class="far fa-kiss-wink-heart fa-fw" aria-hidden="true"></i> LoveIt</a>` -}}
16+
{{- dict "Hugo" $hugo "Theme" $theme | T "poweredBySome" | safeHTML }}
17+
</div>
18+
{{- end -}}
19+
20+
<div class="footer-line" itemscope itemtype="http://schema.org/CreativeWork">
21+
{{- /* Copyright year */ -}}
22+
{{- if ne .Site.Params.footer.copyright false -}}
23+
<i class="far fa-copyright fa-fw" aria-hidden="true"></i>
24+
{{- with .Site.Params.footer.since -}}
25+
<span itemprop="copyrightYear">
26+
{{- if lt . now.Year }}{{ . }} - {{ end }}{{ now.Year -}}
27+
</span>
28+
{{- else -}}
29+
<span itemprop="copyrightYear">{{ now.Year }}</span>
30+
{{- end -}}
31+
{{- end -}}
32+
33+
{{- /* Author */ -}}
34+
{{- if ne .Site.Params.footer.author false -}}
35+
<span class="author" itemprop="copyrightHolder">&nbsp;<a href="{{ $.Site.Params.author.link | default .Site.Home.RelPermalink }}" target="_blank">{{ .Site.Params.author.name }}</a></span>
36+
{{- end -}}
37+
38+
{{- /* License */ -}}
39+
{{- with .Site.Params.footer.license -}}
40+
&nbsp;|&nbsp;<span class="license">{{ . | safeHTML }}</span>
41+
{{- end -}}
42+
43+
{{- /* ICP */ -}}
44+
{{- with .Site.Params.footer.icp -}}
45+
<span class="icp-splitter">&nbsp;|&nbsp;</span><br class="icp-br"/>
46+
<span class="icp">{{ . | safeHTML }}</span>
47+
{{- end -}}
48+
</div>
49+
</div>
50+
</footer>
51+
{{- end -}}

layouts/partials/head/seo.html

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
{{- $params := .Scratch.Get "params" -}}
2+
3+
{{- with .Site.Params.verification.google -}}
4+
<meta name="google-site-verification" content="{{ . }}" />
5+
{{- end -}}
6+
{{- with .Site.Params.verification.bing -}}
7+
<meta name="msvalidate.01" content="{{ . }}" />
8+
{{- end -}}
9+
{{- with .Site.Params.verification.yandex -}}
10+
<meta name="yandex-verification" content="{{ . }}" />
11+
{{- end -}}
12+
{{- with .Site.Params.verification.pinterest -}}
13+
<meta name="p:domain_verify" content="{{ . }}" />
14+
{{- end -}}
15+
{{- with .Site.Params.verification.baidu -}}
16+
<meta name="baidu-site-verification" content="{{ . }}" />
17+
{{- end -}}
18+
19+
{{- /* Home SEO */ -}}
20+
{{- if .IsHome -}}
21+
<script type="application/ld+json">
22+
{
23+
"@context": "http://schema.org",
24+
"@type": "WebSite",
25+
"url": "{{ .Permalink }}",
26+
{{- with .Site.LanguageCode -}}
27+
"inLanguage": "{{ . }}",
28+
{{- end -}}
29+
{{- with .Site.Params.author.name -}}
30+
"author": {
31+
"@type": "Person",
32+
"name": {{ . | safeHTML }}
33+
},
34+
{{- end -}}
35+
{{- with .Site.Params.description -}}
36+
"description": {{ . | safeHTML }},
37+
{{- end -}}
38+
{{- $image := .Site.Params.seo.image -}}
39+
{{- with dict "Path" $image "Resources" .Resources | partial "function/resource.html" -}}
40+
"image": {
41+
"@type": "ImageObject",
42+
"url": "{{ .Permalink }}",
43+
"width": {{ .Width }},
44+
"height": {{ .Height }}
45+
},
46+
{{- else -}}
47+
{{- with $image -}}
48+
"image": "{{ . | absURL }}",
49+
{{- end -}}
50+
{{- end -}}
51+
{{- with .Site.Params.seo.thumbnailUrl -}}
52+
{{- with dict "Path" . "Resources" $.Resources | partial "function/resource.html" -}}
53+
"thumbnailUrl": "{{ .Permalink }}",
54+
{{- else -}}
55+
"thumbnailUrl": "{{ . | absURL }}",
56+
{{- end -}}
57+
{{- end -}}
58+
{{- with .Site.Copyright -}}
59+
"license": "{{ . | safeHTML }}",
60+
{{- end -}}
61+
"name": {{ .Site.Title | safeHTML }}
62+
}
63+
</script>
64+
65+
{{- /* Page SEO */ -}}
66+
{{- else if .IsPage -}}
67+
<script type="application/ld+json">
68+
{
69+
"@context": "http://schema.org",
70+
"@type": "BlogPosting",
71+
"headline": {{ .Title | safeHTML }},
72+
"inLanguage": "{{ .Site.LanguageCode }}",
73+
"mainEntityOfPage": {
74+
"@type": "WebPage",
75+
"@id": "{{ .Permalink }}"
76+
},
77+
{{- $images := $params.seo.images | default slice -}}
78+
{{- if not $images -}}
79+
{{- with .Resources.GetMatch "featured-image-preview" -}}
80+
{{- $images = slice "featured-image-preview" -}}
81+
{{- end -}}
82+
{{- with .Resources.GetMatch "featured-image" -}}
83+
{{- $images = slice "featured-image" -}}
84+
{{- end -}}
85+
{{- end -}}
86+
{{- with .Site.Params.seo.image -}}
87+
{{- $images = $images | default (slice .) -}}
88+
{{- end -}}
89+
{{- with $images -}}
90+
"image": [
91+
{{- range $index, $value := . -}}
92+
{{- if gt $index 0 }},{{ end -}}
93+
{{- with dict "Path" $value "Resources" $.Resources | partial "function/resource.html" -}}
94+
{
95+
"@type": "ImageObject",
96+
"url": "{{ .Permalink }}",
97+
"width": {{ .Width }},
98+
"height": {{ .Height }}
99+
}
100+
{{- else -}}
101+
{{- with $value -}}
102+
"{{ . | absURL }}"
103+
{{- end -}}
104+
{{- end -}}
105+
{{- end -}}
106+
],
107+
{{- end -}}
108+
"genre": "{{ .Type }}",
109+
{{- with .Params.tags -}}
110+
"keywords": "{{ delimit . ", " }}",
111+
{{- end -}}
112+
"wordcount": {{ .WordCount }},
113+
"url": "{{ .Permalink }}",
114+
{{- if not .PublishDate.IsZero -}}
115+
"datePublished": {{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTML }},
116+
{{- else if not .Date.IsZero -}}
117+
"datePublished": {{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }},
118+
{{- end -}}
119+
{{- with .Lastmod -}}
120+
"dateModified": {{ .Format "2006-01-02T15:04:05-07:00" | safeHTML }},
121+
{{- end -}}
122+
{{- with .Site.Copyright -}}
123+
"license": {{ . | safeHTML }},
124+
{{- end -}}
125+
{{- $publisher := .Params.author | default .Site.Params.author.name | default (T "author") | dict "name" -}}
126+
{{- $publisher = $params.seo.publisher | default dict | merge $publisher -}}
127+
"publisher": {
128+
"@type": "Organization",
129+
"name": {{ $publisher.name | safeHTML }}
130+
{{- $logo := $publisher.logoUrl -}}
131+
{{- with dict "Path" $logo "Resources" .Resources | partial "function/resource.html" -}}
132+
,"logo": {
133+
"@type": "ImageObject",
134+
"url": "{{ .Permalink }}",
135+
"width": {{ .Width }},
136+
"height": {{ .Height }}
137+
}
138+
{{- else -}}
139+
{{- with $logo -}}
140+
,"logo": "{{ . | absURL }}"
141+
{{- end -}}
142+
{{- end -}}
143+
},
144+
{{- with .Params.author | default .Site.Params.author.name | default (T "author") -}}
145+
"author": {
146+
"@type": "Person",
147+
"name": {{ . | safeHTML }}
148+
},
149+
{{- end -}}
150+
"description": {{ .Description | safeHTML }}
151+
}
152+
</script>
153+
{{- end -}}

layouts/partials/init.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{- .Scratch.Set "version" "0.2.11" -}}
2+
3+
{{- $params := .Params | merge .Site.Params.page -}}
4+
5+
{{- if eq hugo.Environment "production" -}}
6+
{{- $cdn := .Site.Params.cdn -}}
7+
{{- with $cdn.data -}}
8+
{{- $cdnData := printf "data/cdn/%v" . | resources.Get | transform.Unmarshal -}}
9+
{{- $cdn = dict "simpleIconsPrefix" $cdnData.prefix.simpleIcons -}}
10+
{{- $prefix := $cdnData.prefix.libFiles | default "" -}}
11+
{{- range $key, $value := $cdnData.libFiles -}}
12+
{{- $cdn = printf "%v%v" $prefix $value | dict $key | merge $cdn -}}
13+
{{- end -}}
14+
{{- end -}}
15+
{{- .Scratch.Set "cdn" $cdn -}}
16+
{{- .Scratch.Set "fingerprint" .Site.Params.fingerprint -}}
17+
{{- .Scratch.Set "analytics" .Site.Params.analytics -}}
18+
{{- .Scratch.Set "comment" $params.comment -}}
19+
{{- if eq .Params.comment true -}}
20+
{{- .Scratch.Set "comment" .Site.Params.comment -}}
21+
{{- else if eq .Params.comment false -}}
22+
{{- .Scratch.Set "comment" dict -}}
23+
{{- end -}}
24+
{{- else if eq .Site .Sites.Default -}}
25+
{{- warnf "\n\nCurrent environment is \"development\". The \"comment system\", \"CDN\" and \"fingerprint\" will be disabled.\n当前运行环境是 \"development\". \"评论系统\", \"CDN\" 和 \"fingerprint\" 不会启用.\n" -}}
26+
{{- end -}}
27+
28+
{{- .Scratch.Set "params" $params -}}
29+
{{- .Scratch.Set "this" dict -}}
30+
31+
{{- partial "plugin/compatibility.html" . -}}

layouts/partials/rss/item.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{{- $params := .Page.Params | merge .Site.Params.Page | merge (dict "author" .Site.Params.author.name) -}}
2+
<item>
3+
<title>
4+
{{- .Page.Title -}}
5+
</title>
6+
<link>
7+
{{- .Page.Permalink -}}
8+
</link>
9+
<pubDate>
10+
{{- .Page.Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" -}}
11+
</pubDate>
12+
<author>
13+
{{- $params.author | default (T "author") -}}
14+
</author>
15+
<guid>
16+
{{- .Page.Permalink -}}
17+
</guid>
18+
<description>
19+
{{- "<![CDATA[" | safeHTML -}}
20+
{{- with $params.featuredimage -}}
21+
<div class="featured-image">
22+
<img src="{{ . | relURL }}" referrerpolicy="no-referrer">
23+
</div>
24+
{{- end -}}
25+
{{- $content := .Page.Description -}}
26+
{{- if $params.rssFullText -}}
27+
{{- $content = dict "Content" .Page.Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" -}}
28+
{{- else -}}
29+
{{- with .Page.Summary -}}
30+
{{- $content = dict "Content" . "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" -}}
31+
{{- end -}}
32+
{{- end -}}
33+
{{- $content | replaceRE `<figure[^>]*>.*</figure>` "" | replaceRE `<img[^>]*( /)?>` "" | safeHTML -}}
34+
{{- "]]>" | safeHTML -}}
35+
</description>
36+
</item>

0 commit comments

Comments
 (0)