/
single.html
217 lines (200 loc) · 11.1 KB
/
single.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
{{- define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end -}}
{{- define "content" -}}
{{- $params := .Scratch.Get "params" -}}
{{- $toc := $params.toc -}}
{{- if eq $toc true -}}
{{- $toc = .Site.Params.page.toc | default dict -}}
{{- else if eq $toc false -}}
{{- $toc = dict "enable" false -}}
{{- end -}}
{{- /* Auto TOC */ -}}
{{- if $toc.enable | and (eq $toc.keepStatic false) -}}
<div class="toc" id="toc-auto">
<h2 class="toc-title">{{ T "contents" }}</h2>
<div class="toc-content{{ if eq $toc.auto false }} always-active{{ end }}" id="toc-content-auto">
{{- dict "Content" .TableOfContents "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
</div>
</div>
{{- end -}}
{{- /* TOC Style */ -}}
{{- if eq $toc.enable true -}}
{{- if eq $toc.keepStatic true -}}
<script>document.getElementsByTagName("main")[0].setAttribute("autoTOC", "false")</script>
{{- else -}}
<script>document.getElementsByTagName("main")[0].setAttribute("autoTOC", "true")</script>
{{- end -}}
{{- else if eq $toc.enable false -}}
<script>document.getElementsByTagName("main")[0].setAttribute("autoTOC", "false")</script>
{{- end -}}
<article class="page single">
{{- /* Title */ -}}
<h1 class="single-title animate__animated animate__flipInX">{{ .Title }}</h1>
{{- /* Subtitle */ -}}
{{- with $params.subtitle -}}
<h2 class="single-subtitle">{{ . }}</h2>
{{- end -}}
{{- /* Meta */ -}}
<div class="post-meta">
<div class="post-meta-line">
<span class="post-author">
{{- partial "meta/author.html" . }}
</span>
{{- with .Params.categories | or .Params.series -}}
<span class="post-category">
{{- T "includedIn" | safeHTML -}}
</span>
{{- end -}}
{{- $categories := slice -}}
{{- range .Params.categories -}}
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
{{- $categories = $categories | append (printf `<a href="%v"><i class="far fa-folder fa-fw"></i>%v</a>` $category.RelPermalink $category.Title) -}}
{{- end -}}
{{- with delimit $categories " " -}}
<span class="post-category">
{{- dict "Categories" . "Count" (len $categories) | T "includedInCategories" | safeHTML -}}
</span>
{{- end -}}
{{- with (and (.Params.categories) (.Params.series)) -}}
<span class="post-category">
{{- T "includedInAnd" | safeHTML -}}
</span>
{{- end -}}
{{- $series := slice -}}
{{- range .Params.series -}}
{{- $singleSeries := partialCached "function/path.html" . . | printf "/series/%v" | $.Site.GetPage -}}
{{- $series = $series | append (printf `<a href="%v"><i class="far fa-list-alt fa-fw"></i>%v</a>` $singleSeries.RelPermalink $singleSeries.Title) -}}
{{- end -}}
{{- with delimit $series " " -}}
<span class="post-series">
{{- dict "Series" . | T "includedInSeries" | safeHTML -}}
</span>
{{- end -}}
</div>
<div class="post-meta-line">
{{- with .Site.Params.dateformat | default "2006-01-02" | .PublishDate.Format -}}
<i class="far fa-calendar-alt fa-fw"></i> <time datetime="{{ . }}">{{ . }}</time>
{{- end -}}
{{- with .Site.Params.dateformat | default "2006-01-02" | .Lastmod.Format -}}
<i class="far fa-edit fa-fw"></i> <time datetime="{{ . }}">{{ . }}</time>
{{- end -}}
<i class="fas fa-pencil-alt fa-fw"></i> {{ T "wordCount" .WordCount }}
<i class="far fa-clock fa-fw"></i> {{ T "readingTime" .ReadingTime }}
{{- $comment := .Scratch.Get "comment" | default dict -}}
{{- /* Visitor Count */ -}}
{{- if $comment.enable | and $comment.valine.enable | and $comment.valine.visitor -}}
<span id="{{ .RelPermalink }}" class="leancloud_visitors" data-flag-title="{{ .Title }}">
<i class="far fa-eye fa-fw"></i> <span class="leancloud-visitors-count"></span> {{ T "views" }}
</span>
{{- end -}}
{{- if $comment.enable | and $comment.waline.enable | and $comment.waline.pageview -}}
<span id="{{ .RelPermalink }}" class="leancloud_visitors" data-flag-title="{{ .Title }}">
<i class="far fa-eye fa-fw"></i> <span class="leancloud-visitors-count waline-pageview-count" data-path="{{ .RelPermalink }}"></span> {{ T "views" }}
</span>
{{- end -}}
{{- if $comment.enable | and $comment.twikoo.enable | and $comment.twikoo.visitor -}}
<span id="{{ .RelPermalink }}" class="leancloud_visitors" data-flag-title="{{ .Title }}">
<i class="far fa-eye fa-fw"></i> <span class="leancloud-visitors-count" id=twikoo_visitors></span> {{ T "views" }}
</span>
{{- end -}}
{{- /* Comment Count */ -}}
{{- if $comment.enable | and $comment.waline.enable | and $comment.waline.comment -}}
<span id="{{ .RelPermalink }}" class="comment_count" data-flag-title="{{ .Title }}">
<i class="far fa-comments fa-fw"></i> <span class="waline-comment-count" id="waline-comment-count" data-path="{{ .RelPermalink }}"></span> {{ T "comments" }}
</span>
{{- end -}}
{{- if $comment.enable | and $comment.twikoo.enable | and $comment.twikoo.commentCount -}}
<span id="{{ .RelPermalink }}" class="comment_count" data-flag-title="{{ .Title }}">
<i class="far fa-comments fa-fw"></i> <span class="twikoo-comment-count" id="twikoo-comment-count"></span> {{ T "comments" }}
</span>
{{- end -}}
{{- /* License */ -}}
{{- $license := $params.license -}}
{{- with $license -}}
<span>
<i class="fas fa-balance-scale fa-fw"></i> <span>{{- . | safeHTML -}}</span>
</span>
{{- end -}}
</div>
</div>
{{- /* Featured image */ -}}
{{- $image := $params.featuredimage -}}
{{- $width := "auto" -}}
{{- $height := "auto" -}}
{{- with .Resources.GetMatch (printf "**%s" $params.featuredimage) -}}
{{- if eq .ResourceType "image" -}}
{{- $image = .RelPermalink -}}
{{- $width = .Width -}}
{{- $height = .Height -}}
{{- else -}}
{{- warnf "invalid featured image detected!" -}}
{{- end -}}
{{- end -}}
{{- with .Resources.GetMatch "featured-image" -}}
{{- $image = .RelPermalink -}}
{{- $width = .Width -}}
{{- $height = .Height -}}
{{- end -}}
{{- with $image -}}
<div class="featured-image">
{{- dict "Src" . "Title" $.Description "Resources" $.Resources "Width" $width "Height" $height "Loading" "eager" | partial "plugin/image.html" -}}
</div>
{{- end -}}
{{- /* Series list */ -}}
{{- if $params.series | and $params.seriesNavigation -}}
{{- range $key, $value := .Site.Taxonomies.series -}}
{{- range $params.series -}}
{{- if . | urlize | eq ($key | urlize) -}}
{{- $term := $.Site.GetPage "series" $key -}}
<div class="details series-nav open">
<div class="details-summary series-title">
<span>{{ T "series" }} - {{ $term.Title }}</span>
<span><i class="details-icon fas fa-angle-right"></i></span>
</div>
<div class="details-content series-content">
<nav>
<ul>
{{- range $value.Pages -}}
{{- if .LinkTitle | eq $.Title -}}
<li><span class="active">{{ .LinkTitle }}</span></li>
{{- else }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{- end }}
{{- end -}}
</ul>
</nav>
</div>
</div>
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- /* Static TOC */ -}}
{{- if $toc.enable -}}
<div class="details toc" id="toc-static" kept="{{ if $toc.keepStatic }}true{{ end }}">
<div class="details-summary toc-title">
<span>{{ T "contents" }}</span>
<span><i class="details-icon fas fa-angle-right"></i></span>
</div>
<div class="details-content toc-content" id="toc-content-static">
{{- dict "Content" .TableOfContents "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
</div>
</div>
{{- end -}}
{{- /* Content */ -}}
<div class="content" id="content">
{{- /* Outdated Article Reminder */ -}}
{{- partial "single/outdatedArticleReminder.html" . -}}
{{- dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
</div>
{{/* Related Content */}}
{{- if $params.related.enable -}}
{{- partial "related.html" . -}}
{{- end -}}
{{/* Sponsor */}}
{{- partial "single/sponsor.html" . -}}
{{- /* Footer */ -}}
{{- partial "single/footer.html" . -}}
{{- /* Comment */ -}}
{{- partial "comment.html" . -}}
</article>
{{- end -}}