LoveIt/layouts/posts/single.html

110 lines
5.1 KiB
HTML
Raw Normal View History

2020-01-31 15:53:04 +01:00
{{- define "title" }}{{ .Title }} | {{ .Site.Title }}{{ end -}}
2019-08-04 15:53:35 +02:00
2020-01-31 15:53:04 +01:00
{{- define "content" -}}
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormatToUse | default "2006-01-02") -}}
{{- $author := .Params.author | default .Site.Author.name -}}
{{- $author_link := .Params.author_link | default .Site.Author.link | default .Site.BaseURL -}}
2019-08-04 15:53:35 +02:00
<article class="page">
2019-08-24 13:32:41 +02:00
<h1 class="post-title animated flipInX">{{ .Title }}</h1>
<div class="post-meta">
<div class="post-meta-main">
<a class="author" href="{{ $author_link }}" rel="author" target="_blank">
<i class="fas fa-user-circle fa-fw"></i>{{ $author }}&nbsp;
</a>
2020-01-31 15:53:04 +01:00
{{- with .Params.categories -}}
2019-08-04 15:53:35 +02:00
<span class="post-category">
{{- T "included" -}}&nbsp;
2020-01-31 15:53:04 +01:00
{{- range . -}}
2019-08-04 15:53:35 +02:00
{{- $name := . -}}
{{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}}
<i class="far fa-folder fa-fw"></i><a href="{{ .Permalink }}">{{ $name | humanize }}</a>
2020-01-31 15:53:04 +01:00
{{- end -}}
{{- end -}}
2019-08-04 15:53:35 +02:00
</span>
2020-01-31 15:53:04 +01:00
{{- end -}}
2019-08-04 15:53:35 +02:00
</div>
<div class="post-meta-other">
<i class="far fa-calendar-alt fa-fw"></i><time datetime={{ $publish_date }}>{{ $publish_date }}</time>&nbsp;
<i class="fas fa-pencil-alt fa-fw"></i>{{ T "wordCount" .WordCount }}&nbsp;
<i class="far fa-clock fa-fw"></i>{{ T "readingTime" .ReadingTime }}&nbsp;
{{- 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 fa-fw"></i>{{ T "pageviews" | safeHTML }}
</span>&nbsp;
{{- end -}}
</div>
</div>
2020-01-31 15:53:04 +01:00
{{- with .Params.featured_image -}}
<div class="post-featured-image">
2020-01-31 15:53:04 +01:00
{{- $res := resources.Get "svg/loading.svg" | minify -}}
2020-01-31 11:46:28 +01:00
<img src="{{ $res.RelPermalink }}" data-sizes="auto" data-src="{{ . }}" alt="featured image" class="lazyload">
</div>
2020-01-31 15:53:04 +01:00
{{- end -}}
2019-08-19 21:01:15 +02:00
2020-01-31 15:53:04 +01: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.auto_collapse_toc | default true }}
<div class="post-toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.auto_collapse_toc false)) }} always-active{{ end }}">
2020-01-31 15:53:04 +01:00
{{- .TableOfContents -}}
</div>
</div>
2019-08-19 21:01:15 +02:00
<div class="post-toc-mobile" id="post-toc-mobile">
<details>
2020-01-31 15:53:04 +01:00
<summary>
<div class="post-toc-title">
<span>{{ T "toc" }}</span>
<span><i class="details icon fas fa-angle-down"></i></span>
</div>
</summary>
2019-08-19 21:01:15 +02:00
<div class="post-toc-content">
2020-01-31 15:53:04 +01:00
{{- $toc := .TableOfContents -}}
{{- $toc = replaceRE `id="TableOfContents"` `id="TableOfContentsMobile"` $toc -}}
{{- $toc | safeHTML -}}
2019-08-19 21:01:15 +02:00
</div>
</details>
</div>
2020-01-31 15:53:04 +01:00
{{- end -}}
2019-08-18 19:36:52 +02:00
<div class="post-content">
2020-01-31 15:53:04 +01:00
{{- $content := .Content -}}
{{- $REin := `:\(([\w- ]+?)\):` -}}
{{- $REout := `<i class="$1 fa-fw"></i>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `\[(.+?)\]\^\((.+?)\)` -}}
{{- $REout = `<strong><ruby>$1<rt>$2</rt></ruby></strong>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<sup>\[return\]</sup>` -}}
{{- $REout = `↩︎` -}}
2020-01-31 15:53:04 +01:00
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(h[23456]) (id=".+?")>` -}}
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<(.+?) (id="fnref:.+?")>` -}}
2020-01-31 15:53:04 +01:00
{{- $REout = `<a class="post-dummy-target" $2></a><$1>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $REin = `<li (id="fn:.+?")(.*?)>\s?<p>` -}}
{{- $REout = `<li $2><p><a class="post-dummy-target" $1></a>` -}}
{{- $content = replaceRE $REin $REout $content -}}
2020-01-31 15:53:04 +01:00
{{- $content | safeHTML -}}
2019-08-04 15:53:35 +02:00
</div>
2020-01-31 15:53:04 +01:00
{{- partial "post/footer.html" . -}}
2019-08-04 15:53:35 +02:00
<div class="post-comment">
2020-01-31 15:53:04 +01:00
{{- if ( .Params.comment | default true ) -}}
{{- partial "comments.html" . -}}
{{- end -}}
2019-08-04 15:53:35 +02:00
</div>
</article>
2020-01-31 15:53:04 +01:00
{{- end -}}