LeaveItFork/layouts/_default/single.html

111 lines
4.7 KiB
HTML
Raw Normal View History

2018-09-12 16:14:09 +00:00
{{ define "content" -}}
{{ $cdn_url := .Scratch.Get "cdn_url" }}
<article class="post-warp" itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">{{ .Title }}</h1>
<div class="post-meta">
Written by <a itemprop="name" href="{{.Site.BaseURL }}" rel="author">{{ if isset .Params "author" }}{{ .Params.author }}{{ else }}{{ .Site.Params.author }}{{ end }}</a> with ♥
2018-09-12 16:14:09 +00:00
<span class="post-time">
on <time datetime={{.Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} itemprop="datePublished">{{ .Date.Format (.Site.Params.dateFormatToUse | default "January 2, 2006") }}</time>
</span>
in
{{ with .Params.categories -}}
<i class="iconfont icon-folder"></i>
<span class="post-category">
{{ range . }}
{{- $name := . -}}
{{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}}
<a href="{{ .Permalink }}"> {{ $name }} </a>
{{ end -}}
{{ end }}
</span>
{{- end }}
|
<a href="#gitalk-container" itemprop="discussionUrl">
<span class="gitalk-comment-count" itemprop="commentCount"></span>
</a>
{{ .Site.Params.gitalk.countSign }}
2018-09-12 16:14:09 +00:00
</div>
</header>
{{ partial "toc.html" . }}
2018-09-12 16:14:09 +00:00
<div class="post-content">
<!--featured_image-->
{{ $images := findRE "<img src=\"[^\"|\\\"]*\"" .Content -}}
{{ if ge (len $images) 1}}
{{ $.Scratch.Set "postHasImages" true }}
{{ end }}
{{ with .Params.featured_image }}
{{- $img := . -}}
<img src="{{ printf "%s%s" $cdn_url $img }}" class="featured_image">
{{ end }}
<!-- end featured_image-->
2018-09-12 16:14:09 +00:00
{{ $reAltIn := "<img src=\"([^\"]+)\" alt=\"([^\"]+)?\" />" }}
{{ $reAltOut := ( printf "<figure><img src=\"/images/ring.svg\" data-sizes=\"auto\" data-src=\"%s$1\" alt=\"$2\" class=\"lazyload\"><figcaption class=\"image-caption\">$2</figcaption></figure>" $cdn_url ) }}
{{ $altContent := .Content | replaceRE $reAltIn $reAltOut | safeHTML }}
{{ $reAltTitleIn := "<img src=\"([^\"]+)\" alt=\"([^\"]+)?\" title=\"([^\"]+)?\" />" }}
{{ $reAltTitleOut := ( printf "<figure><img src=\"/images/ring.svg\" data-src=\"%s$1\" data-sizes=\"auto\" alt=\"$2\" title=\"$3\" class=\"lazyload\"><figcaption class=\"image-caption\">$2</figcaption></figure>" $cdn_url ) }}
{{ $finalContent := $altContent | replaceRE $reAltTitleIn $reAltTitleOut | safeHTML }}
{{ $finalContent }}
</div>
<div class="post-copyright">
{{ with .Site.Params.author }}
2018-09-12 16:14:09 +00:00
<p class="copyright-item">
<span>Author:</span>
<span>{{ . }} </span>
</p>
{{ end }}
{{ with .Permalink }}
2018-09-12 16:14:09 +00:00
<p class="copyright-item">
<span>Link:</span>
2018-10-11 06:45:47 +00:00
<a href={{ . }}>
<script>
document.write(decodeURI(location))
</script>
</a>
2018-09-12 16:14:09 +00:00
</p>
{{ end }}
{{ with .Site.Params.license }}
2018-09-12 16:14:09 +00:00
<p class="copyright-item lincese">
{{ . | safeHTML}}
</p>
{{ end }}
</div>
2018-09-12 16:14:09 +00:00
<div class="post-tags">
{{ with .Params.tags }}
<section>
<i class="iconfont icon-tag"></i>Tag(s):
{{ range . }}
<span class="tag"><a href="{{ "tags/" | absURL }}{{ . | urlize }}/">
#{{.}}</a></span>
{{ end }}
</section>
2018-09-12 16:14:09 +00:00
{{ end }}
<section>
<a href="javascript:window.history.back();">back</a></span> ·
<span><a href="{{ .Site.BaseURL }}">home</a></span>
2018-09-12 16:14:09 +00:00
</section>
</div>
2018-09-15 09:25:36 +00:00
2018-09-12 16:14:09 +00:00
<div class="post-nav">
{{ if .PrevInSection }}
<a href="{{.PrevInSection.Permalink}}" class="prev" rel="prev" title="{{ .PrevInSection.Title}}"><i class="iconfont icon-left"></i>&nbsp;{{ .PrevInSection.Title}}</a>
{{ end }}
2018-09-12 16:14:09 +00:00
{{ if .NextInSection }}
<a href="{{.NextInSection.Permalink}}" class="next" rel="next" title="{{.NextInSection.Title}}">{{.NextInSection.Title}}&nbsp;<i class="iconfont icon-right"></i></a>
{{ end }}
</div>
</article>
{{- end }}