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" >
2018-10-11 06:31:20 +00:00
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 }}
2018-10-11 03:12:00 +00:00
|
< a href = "#gitalk-container" itemprop = "discussionUrl" >
2018-10-11 06:31:20 +00:00
< span class = "gitalk-comment-count" itemprop = "commentCount" > < / span >
2018-10-11 03:12:00 +00:00
< / a >
{{ .Site.Params.gitalk.countSign }}
2018-09-12 16:14:09 +00:00
< / div >
< / header >
2018-10-11 03:12:00 +00:00
{{ 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-10-11 06:31:20 +00:00
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" >
2018-10-11 06:31:20 +00:00
{{ with .Site.Params.author }}
2018-09-12 16:14:09 +00:00
< p class = "copyright-item" >
< span > Author:< / span >
< span > {{ . }} < / span >
< / p >
{{ end }}
2018-10-11 06:31:20 +00:00
{{ with .Permalink }}
2018-09-12 16:14:09 +00:00
< p class = "copyright-item" >
< span > Link:< / span >
< a href = {{ . } } > {{ . }}< / span >
< / p >
{{ end }}
2018-10-11 06:31:20 +00:00
{{ with .Site.Params.license }}
2018-09-12 16:14:09 +00:00
< p class = "copyright-item lincese" >
{{ . | safeHTML}}
< / p >
{{ end }}
< / div >
2018-10-11 06:31:20 +00:00
2018-09-12 16:14:09 +00:00
< div class = "post-tags" >
2018-09-16 12:20:40 +00:00
{{ with .Params.tags }}
< section >
2018-10-11 06:31:20 +00:00
< i class = "iconfont icon-tag" > < / i > Tag(s):
2018-09-16 12:20:40 +00:00
{{ range . }}
< span class = "tag" > < a href = "{{ " tags / " | absURL } } { { . | urlize } } / " >
#{{.}}< / a > < / span >
{{ end }}
< / section >
2018-09-12 16:14:09 +00:00
{{ end }}
2018-09-16 12:20:40 +00:00
< section >
2018-10-11 06:31:20 +00:00
< a href = "javascript:window.history.back();" > back< / a > < / span > ·
2018-09-16 12:20:40 +00:00
< 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 > {{ .PrevInSection.Title}}< / a >
2018-10-11 06:31:20 +00:00
{{ end }}
2018-09-12 16:14:09 +00:00
{{ if .NextInSection }}
< a href = "{{.NextInSection.Permalink}}" class = "next" rel = "next" title = "{{.NextInSection.Title}}" > {{.NextInSection.Title}} < i class = "iconfont icon-right" > < / i > < / a >
{{ end }}
< / div >
< / article >
{{- end }}