LoveIt/layouts/posts/single.html

114 lines
4.9 KiB
HTML
Raw Normal View History

2019-08-04 15:53:35 +02: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-11 19:36:19 +02:00
{{ $author := .Site.Author.Name }}
2019-08-04 15:53:35 +02:00
{{ if isset .Params "author" }}
2019-08-11 19:36:19 +02:00
{{ $author = .Site.Author.Name }}
2019-08-04 15:53:35 +02:00
{{ end }}
<article class="post-warp">
<header class="post-header">
<h1 class="post-title">{{ .Title }}</h1>
<div class="post-meta">
<a href="{{.Site.BaseURL }}" rel="author">{{ $author }}</a>
{{ T "wrote" }}
<span class="post-time"><time datetime={{ $publish_date }}>{{ $publish_date }}</time></span>
&nbsp;
{{ T "wordCount" .WordCount }}
<i class="iconfont icon-timer"></i>
{{ T "readingTime" .ReadingTime }}
&nbsp;
{{ 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))) -}}
<i class="iconfont icon-folder"></i>
<a href="{{ .Permalink }}">{{ $name }}</a>
{{ end -}}
{{ end }}
</span>
{{- end }}
</div>
</header>
<div class="post-content">
<!--featured_image-->
{{ with .Params.featured_image }}
2019-08-11 19:36:19 +02:00
<img src="{{ . }}" class="featured_image">
2019-08-04 15:53:35 +02:00
{{ end }}
<!-- end featured_image-->
2019-08-11 19:36:19 +02: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 15:53:35 +02:00
{{ $altContent := .Content | replaceRE $reAltIn $reAltOut | safeHTML }}
2019-08-11 19:36:19 +02: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 15:53:35 +02:00
{{ $finalContent := $altContent | replaceRE $reAltTitleIn $reAltTitleOut | safeHTML }}
{{ $finalContent }}
</div>
<div class="post-copyright">
<p class="copyright-item">
<span>{{ T "author" }}:</span>
<span><a href="{{.Site.BaseURL }}" rel="author">{{ $author }}</a></span>
</p>
<p class="copyright-item">
<span>{{ T "lastMod" }}:</span>
<span>{{ $modify_date }}</span>
</p>
<p class="copyright-item">
{{ if and ( $.Param "socialShare" ) (gt (len ($.Param "share")) 0) }}
<span>{{ T "share" }}:</span>
2019-08-11 19:36:19 +02:00
<span>{{ partial "post/share-links.html" . }}</span>
2019-08-04 15:53:35 +02:00
{{ end }}
</p>
{{ with .Site.Params.license }}
<p class="copyright-item">
<span>{{ T "license" }}:</span>
<span>{{ . | safeHTML }}</span>
</p>
{{ end }}
</div>
<div class="post-tags">
{{ with .Params.tags }}
<section>
<i class="iconfont icon-icon-tag"></i>{{ T "tag" }}:
{{ range . }}
<span class="tag">
<a href="{{ "tags/" | absURL }}{{ . | urlize }}/">#{{.}}</a>
</span>
{{ end }}
</section>
{{ end }}
<section>
2019-08-06 05:44:15 +02:00
<span><a href="javascript:window.history.back();">{{ T "back" }}</a></span>
2019-08-06 05:42:24 +02:00
|
2019-08-04 15:53:35 +02:00
<span><a href="{{ .Site.BaseURL }}">{{ T "home" }}</a></span>
</section>
</div>
<div class="post-nav">
{{ if .PrevInSection }}
<a href="{{.PrevInSection.Permalink}}" class="prev" rel="prev" title="{{ .PrevInSection.Title}}"><i
class="iconfont icon-dajiantou"></i>&nbsp;{{ .PrevInSection.Title}}</a>
{{ end }}
{{ if .NextInSection }}
<a href="{{.NextInSection.Permalink}}" class="next" rel="next"
title="{{.NextInSection.Title}}">{{.NextInSection.Title}}&nbsp;<i class="iconfont icon-xiaojiantou"></i></a>
{{ end }}
</div>
<div class="post-comment">
{{ if ( .Params.showComments | default true ) }}
2019-08-05 15:15:01 +02:00
{{ partial "comments.html" . }}
2019-08-04 15:53:35 +02:00
{{ end }}
</div>
</article>
{{- end }}