2019-08-04 21:53:35 +08:00
{{ define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end }}
{{ define "content" }}
{{ $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }}
{{ $modify_date := .Lastmod.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }}
2019-08-17 03:40:34 +08:00
{{ $author := .Site.Author.name }}
2019-08-04 21:53:35 +08:00
{{ if isset .Params "author" }}
2019-08-17 03:40:34 +08:00
{{ $author = .Site.Author.name }}
2019-08-04 21:53:35 +08:00
{{ end }}
< article class = "post-warp" >
< header class = "post-header" >
< h1 class = "post-title" > {{ .Title }}< / h1 >
2019-08-17 03:40:34 +08:00
< / header >
< div class = "post-meta" >
< div class = "post-meta-main" >
2019-08-04 21:53:35 +08:00
< a href = "{{.Site.BaseURL }}" rel = "author" > {{ $author }}< / a >
2019-08-17 03:40:34 +08:00
{{ T "included" }}
2019-08-04 21:53:35 +08:00
{{ with .Params.categories -}}
< span class = "post-category" >
{{ range . }}
{{- $name := . -}}
{{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}}
2019-08-17 23:16:09 +08:00
< i class = "far fa-folder" > < / i > < a href = "{{ .Permalink }}" > {{ $name }}< / a >
2019-08-04 21:53:35 +08:00
{{ end -}}
{{ end }}
< / span >
{{- end }}
< / div >
2019-08-17 23:16:09 +08:00
2019-08-17 03:40:34 +08:00
< div class = "post-meta-other" >
2019-08-17 23:16:09 +08:00
< span class = "post-time" > < i class = "far fa-calendar-alt" > < / i > < time datetime = {{ $ publish_date } } > {{ $publish_date }}< / time > < / span >
< i class = "fas fa-pencil-alt" > < / i > {{ T "wordCount" .WordCount }}
< i class = "far fa-clock" > < / i > {{ T "readingTime" .ReadingTime }}
{{- if eq (getenv "HUGO_ENV") "production" | and .Site.Params.valine.enable | and .Site.Params.valine.visitor -}}
< span id = "{{ .RelPermalink | relURL }}" class = "leancloud_visitors" data-flag-title = "{{ .Title }}" >
< i class = "far fa-eye" > < / i > {{ T "pageviews" | safeHTML }}
< / span >
{{- end -}}
2019-08-17 03:40:34 +08:00
< / div >
< / div >
2019-08-17 23:16:09 +08:00
{{ if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
< div class = "post-toc" id = "post-toc" >
< h2 class = "post-toc-title" > {{ T "toc" }}< / h2 >
{{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default true }}
< div class = "post-toc-content{{ if not (or .Params.autoCollapseToc (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false))) }} always-active{{ end }}" >
{{.TableOfContents}}
< / div >
< / div >
{{- end }}
2019-08-04 21:53:35 +08:00
< div class = "post-content" >
<!-- featured_image -->
{{ with .Params.featured_image }}
2019-08-17 23:16:09 +08:00
< img src = /images/loading.svg data-sizes = auto data-src = {{ . } } alt = "featured image" class = "featured_image lazyload" >
2019-08-04 21:53:35 +08:00
{{ end }}
<!-- end featured_image -->
2019-08-12 01:36:19 +08:00
{{ $reAltIn := `< img src = "([^" ] + ) " alt = "([^" ] + ) ? " / > ` }}
{{ $reAltOut := "< figure > < img src = /images/loading.svg data-sizes = auto data-src = $1 alt = $2 class = lazyload > < figcaption class = image-caption > $2< / figcaption > < / figure > " }}
2019-08-04 21:53:35 +08:00
{{ $altContent := .Content | replaceRE $reAltIn $reAltOut | safeHTML }}
2019-08-12 01:36:19 +08:00
{{ $reAltTitleIn := `< img src = "([^" ] + ) " alt = "([^" ] + ) ? " title = "([^" ] + ) ? " / > ` }}
{{ $reAltTitleOut := "< figure > < img src = /images/loading.svg data-src = $1 data-sizes = auto alt = $2 title = $3 class = lazyload > < figcaption class = image-caption > $2< / figcaption > < / figure > " }}
2019-08-04 21:53:35 +08:00
{{ $finalContent := $altContent | replaceRE $reAltTitleIn $reAltTitleOut | safeHTML }}
{{ $finalContent }}
< / div >
2019-08-17 23:16:09 +08:00
< div class = "post-footer" >
< div class = "post-info" >
< div class = "post-info-mod" > < span > {{ printf (T "lastMod") $modify_date }}< / span > < / div >
< div class = "post-info-share" >
{{ if and ( $.Param "socialShare" ) (gt (len ($.Param "share")) 0) }}
< span > {{ partial "post/share-links.html" . }}< / span >
{{ end }}
< / div >
< / div >
2019-08-04 21:53:35 +08:00
2019-08-17 23:16:09 +08:00
< div class = "post-tags" >
< section >
{{ with .Params.tags }}
{{ range . }}
< span class = "tag" >
< i class = "fas fa-tag" > < / i > < a href = "{{ " tags / " | absURL } } { { . | urlize } } / " > {{.}} < / a >
< / span >
{{ end }}
{{ end }}
< / section >
< section >
< span > < a href = "javascript:window.history.back();" > {{ T "back" }}< / a > < / span > | < span > < a href = "{{ .Site.BaseURL }}" > {{ T "home" }}< / a > < / span >
< / section >
< / div >
2019-08-04 21:53:35 +08:00
2019-08-17 23:16:09 +08:00
< div class = "post-nav" >
{{ if .PrevInSection }}
< a href = "{{.PrevInSection.Permalink}}" class = "prev" rel = "prev" title = "{{ .PrevInSection.Title}}" > < i class = "fas fa-angle-left" > < / i > {{ .PrevInSection.Title}}< / a >
2019-08-04 21:53:35 +08:00
{{ end }}
2019-08-17 23:16:09 +08:00
{{ if .NextInSection }}
< a href = "{{.NextInSection.Permalink}}" class = "next" rel = "next" title = "{{.NextInSection.Title}}" > {{.NextInSection.Title}} < i class = "fas fa-angle-right" > < / i > < / a >
2019-08-04 21:53:35 +08:00
{{ end }}
2019-08-17 23:16:09 +08:00
< / div >
2019-08-04 21:53:35 +08:00
< / div >
< div class = "post-comment" >
{{ if ( .Params.showComments | default true ) }}
2019-08-05 21:15:01 +08:00
{{ partial "comments.html" . }}
2019-08-04 21:53:35 +08:00
{{ end }}
< / div >
< / article >
{{- end }}