LoveIt/layouts/posts/single.html

111 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") }}
{{ $author := .Site.Author.name }}
2019-08-04 15:53:35 +02:00
{{ if isset .Params "author" }}
{{ $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>
</header>
<div class="post-meta">
<div class="post-meta-main">
2019-08-04 15:53:35 +02:00
<a href="{{.Site.BaseURL }}" rel="author">{{ $author }}</a>
{{ T "included" }}
2019-08-04 15:53:35 +02: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-16 22:48:39 +02:00
<i class="far fa-folder"></i>&nbsp;
2019-08-04 15:53:35 +02:00
<a href="{{ .Permalink }}">{{ $name }}</a>
{{ end -}}
{{ end }}
</span>
{{- end }}
</div>
<div class="post-meta-other">
2019-08-16 22:48:39 +02:00
<i class="far fa-calendar-alt"></i>&nbsp;
2019-08-16 22:53:27 +02:00
<span class="post-time"><time datetime={{ $publish_date }}>{{ $publish_date }}</time></span>&nbsp;
<i class="fas fa-pencil-alt"></i>&nbsp;
{{ T "wordCount" .WordCount }}&nbsp;
<i class="far fa-clock"></i>&nbsp;
{{ T "readingTime" .ReadingTime }}&nbsp;
{{ if and .Site.Params.valine.enable .Site.Params.valine.visitor }}
<span id="{{ .RelPermalink | relURL }}" class="leancloud_visitors" data-flag-title="{{ .Title }}">
2019-08-16 22:53:27 +02:00
<i class="far fa-eye"></i>
{{ T "pageviews" | safeHTML }}
</span>
{{ end }}
</div>
</div>
2019-08-04 15:53:35 +02:00
<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-info">
<p class="post-info-item">
2019-08-04 15:53:35 +02:00
<span>{{ T "lastMod" }}:</span>
<span>{{ $modify_date }}</span>
</p>
<p class="post-info-item">
2019-08-04 15:53:35 +02:00
{{ if and ( $.Param "socialShare" ) (gt (len ($.Param "share")) 0) }}
<span>{{ T "share" }}:</span>
<span>{{ partial "post/share-links.html" . }}</span>
2019-08-04 15:53:35 +02:00
{{ end }}
</p>
</div>
<div class="post-tags">
<section>
{{ with .Params.tags }}
{{ range . }}
<span class="tag">
<i class="fas fa-tag"></i><a href="{{ "tags/" | absURL }}{{ . | urlize }}/">&nbsp;{{.}}&nbsp;</a>
</span>
{{ end }}
2019-08-04 15:53:35 +02:00
{{ end }}
</section>
<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="fas fa-angle-left"></i>&nbsp;{{ .PrevInSection.Title}}</a>
2019-08-04 15:53:35 +02:00
{{ end }}
{{ if .NextInSection }}
<a href="{{.NextInSection.Permalink}}" class="next" rel="next" title="{{.NextInSection.Title}}">{{.NextInSection.Title}}&nbsp;<i class="fas fa-angle-right"></i></a>
2019-08-04 15:53:35 +02:00
{{ 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 }}