215 lines
11 KiB
Plaintext
215 lines
11 KiB
Plaintext
{{- define "title" }}{{ .Title }} - {{ .Site.Title }}{{ end -}}
|
|
|
|
{{- define "content" -}}
|
|
{{- $params := .Scratch.Get "params" -}}
|
|
{{- $toc := .Scratch.Get "toc" -}}
|
|
|
|
<aside class="toc" id="toc-auto">
|
|
{{- /* Auto TOC */ -}}
|
|
{{- $tocEmpty := eq .TableOfContents `<nav id="TableOfContents"></nav>` -}}
|
|
{{- if (ne $toc.enable false) | and (ne $tocEmpty true) -}}
|
|
<h2 class="toc-title{{ with $params.password }} d-none{{ end }}">
|
|
{{- T "single.contents" -}}
|
|
{{- dict "Class" "toc-icon fa-solid fa-angle-down fa-fw" | partial "plugin/icon.html" -}}
|
|
</h2>
|
|
<div class="toc-content{{ if eq $toc.auto false }} always-active{{ end }}{{ with $params.password }} d-none{{ end }}" id="toc-content-auto"></div>
|
|
{{- end -}}
|
|
</aside>
|
|
|
|
<aside class="aside-custom">
|
|
<!-- put aside for later use -->
|
|
{{- partial (.Scratch.Get "customFilePath").aside . -}}
|
|
</aside>
|
|
|
|
<article class="page single">
|
|
<div class="header">
|
|
{{- /* Title */ -}}
|
|
<h1 class="single-title animate__animated animate__flipInX">
|
|
{{- $repost := $params.repost | default dict -}}
|
|
{{- with $repost -}}
|
|
{{- if eq .Enable true -}}
|
|
{{- $icon := dict "Class" "fa-solid fa-share fa-fw" -}}
|
|
{{- $title := cond (hasPrefix .Url "http") (printf "%v -> %v" (T "single.repost") .Url ) (T "single.repost") -}}
|
|
{{- if hasPrefix .Url "http" -}}
|
|
{{ dict "Destination" .Url "Icon" $icon "Class" "icon-repost" "Title" $title | partial "plugin/link.html" -}}
|
|
{{- else -}}
|
|
<span title="{{ $title }}" class="icon-repost">{{- $icon | partial "plugin/icon.html" -}}</span>
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
<span>{{- .Title -}}</span>
|
|
</h1>
|
|
|
|
{{- /* Subtitle */ -}}
|
|
{{- with $params.subtitle -}}<p class="single-subtitle animate__animated animate__fadeIn">{{ . }}</p>{{- end -}}
|
|
</div>
|
|
|
|
{{- /* Meta */ -}}
|
|
<div class="post-meta">
|
|
<div class="post-meta-line">
|
|
{{- partial "single/post-author.html" . -}}
|
|
|
|
{{- $categories := slice -}}
|
|
{{- range .Params.categories -}}
|
|
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
|
|
{{- $categories = $categories | append (printf `<a href="%v">%v %v</a>` (partial "function/escapeurl.html" $category.RelPermalink) (dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html") $category.Title) -}}
|
|
{{- end -}}
|
|
{{- with delimit $categories " " }}
|
|
<span class="post-category">
|
|
{{- dict "Categories" . | T "single.includedInCategories" | safeHTML -}}
|
|
</span>
|
|
{{- end -}}
|
|
</div>
|
|
<div class="post-meta-line">
|
|
{{- with .Site.Params.dateformat | default "2006-01-02" | .PublishDate.Format -}}
|
|
<span title="{{ dict "Date" ("2006-01-02 15:04:05" | $.PublishDate.Format) | T "single.publishedOnDate" }}">
|
|
{{- dict "Class" "fa-regular fa-calendar-alt fa-fw me-1" | partial "plugin/icon.html" -}}
|
|
{{- printf `<time datetime="%v">%v</time>` . . | safeHTML -}}
|
|
</span>
|
|
{{- end -}}
|
|
{{- with .Site.Params.dateformat | default "2006-01-02" | .Lastmod.Format -}}
|
|
<span title="{{ dict "Date" ("2006-01-02 15:04:05" | $.Lastmod.Format) | T "single.updatedOnDate" }}">
|
|
{{- dict "Class" "fa-regular fa-edit fa-fw me-1" | partial "plugin/icon.html" -}}
|
|
{{- printf `<time datetime="%v">%v</time>` . . | safeHTML -}}
|
|
</span>
|
|
{{- end -}}
|
|
{{- if $params.wordCount -}}
|
|
<span>
|
|
{{- dict "Class" "fa-solid fa-pencil-alt fa-fw me-1" | partial "plugin/icon.html" -}}
|
|
{{- T "single.wordCount" .WordCount -}}
|
|
</span>
|
|
{{- end -}}
|
|
{{- if $params.readingTime -}}
|
|
<span>
|
|
{{- dict "Class" "fa-regular fa-clock fa-fw me-1" | partial "plugin/icon.html" -}}
|
|
{{- T "single.readingTime" .ReadingTime -}}
|
|
</span>
|
|
{{- end -}}
|
|
|
|
{{- /* If the article expires, close the comment or not */ -}}
|
|
{{- $expirationReminder := $params.expirationReminder | default dict -}}
|
|
{{- if
|
|
$expirationReminder.enable
|
|
| and (gt (div (sub now.Unix .Lastmod.Unix) 86400) ($expirationReminder.warning | default 180))
|
|
| and $expirationReminder.closeComment -}}
|
|
{{- .Scratch.Set "commentExpired" true -}}
|
|
{{- end -}}
|
|
{{- $comment := .Scratch.Get "comment" | default dict -}}
|
|
{{- $visitorIcon := dict "Class" "fa-regular fa-eye fa-fw me-1" | partial "plugin/icon.html" -}}
|
|
{{- $commentIcon := dict "Class" "fa-regular fa-comments fa-fw me-1" | partial "plugin/icon.html" -}}
|
|
{{- /* Visitor Count */ -}}
|
|
{{- if $comment.enable -}}
|
|
{{- if $comment.artalk.enable -}}
|
|
<span class="comment-visitors" data-flag-title="{{ .Title }}">
|
|
{{ $visitorIcon }}<span class="artalk-visitor-count" data-page-key="{{ .RelPermalink }}">-</span> {{ T "single.views" }}
|
|
</span>
|
|
{{- else if ($comment.valine.enable | and $comment.valine.visitor) -}}
|
|
<span id="{{ .RelPermalink }}" class="leancloud_visitors comment-visitors" data-flag-title="{{ .Title }}">
|
|
{{ $visitorIcon }}<span class="leancloud-visitors-count">-</span> {{ T "single.views" }}
|
|
</span>
|
|
{{- else if $comment.waline.enable | and $comment.waline.pageview -}}
|
|
<span class="comment-visitors" data-flag-title="{{ .Title }}">
|
|
{{ $visitorIcon }}<span data-path="{{ .RelPermalink }}" class="waline-pageview-count">-</span> {{ T "single.views" }}
|
|
</span>
|
|
{{- else if $comment.twikoo.enable | and $comment.twikoo.visitor -}}
|
|
<span id="{{ .RelPermalink }}" class="comment-visitors" data-flag-title="{{ .Title }}">
|
|
{{ $visitorIcon }}<span id="twikoo_visitors">-</span> {{ T "single.views" }}
|
|
</span>
|
|
{{- else if .Site.Params.ibruce.enable | and .Site.Params.ibruce.enablePost -}}
|
|
<span id="busuanzi_container_page_pv" class="busuanzi_visitors comment-visitors" data-flag-title="{{ .Title }}">
|
|
{{ $visitorIcon }}<span id="busuanzi_value_page_pv">-</span> {{ T "single.views" }}
|
|
</span>
|
|
{{- end -}}
|
|
{{- else if .Site.Params.ibruce.enable | and .Site.Params.ibruce.enablePost -}}
|
|
<span id="busuanzi_container_page_pv" class="busuanzi_visitors comment-visitors" data-flag-title="{{ .Title }}">
|
|
{{ $visitorIcon }}<span id="busuanzi_value_page_pv">-</span> {{ T "single.views" }}
|
|
</span>
|
|
{{- end -}}
|
|
{{- /* Comment Count */ -}}
|
|
{{- if $comment.enable -}}
|
|
{{- if $comment.artalk.enable -}}
|
|
<span class="comment-count" data-flag-title="{{ .Title }}">
|
|
{{ $commentIcon }}<span class="artalk-comment-count" data-page-key="{{ .RelPermalink }}">-</span> {{ T "single.comments" }}
|
|
</span>
|
|
{{- else if $comment.valine.enable | and $comment.valine.commentCount -}}
|
|
<span class="comment-count" data-flag-title="{{ .Title }}">
|
|
{{ $commentIcon }}<span data-xid="{{ .RelPermalink }}" class="valine-comment-count">-</span> {{ T "single.comments" }}
|
|
</span>
|
|
{{- else if $comment.waline.enable | and $comment.waline.comment -}}
|
|
<span class="comment-count" data-flag-title="{{ .Title }}">
|
|
{{ $commentIcon }}<span data-path="{{ .RelPermalink }}" class="waline-comment-count">-</span> {{ T "single.comments" }}
|
|
</span>
|
|
{{- else if $comment.twikoo.enable | and $comment.twikoo.commentCount -}}
|
|
<span id="{{ .RelPermalink }}" class="comment-count" data-flag-title="{{ .Title }}">
|
|
{{ $commentIcon }}<span id="twikoo-comment-count">-</span> {{ T "single.comments" }}
|
|
</span>
|
|
{{- end -}}
|
|
{{- end -}}
|
|
</div>
|
|
</div>
|
|
|
|
{{- /* Featured image */ -}}
|
|
{{- $image := $params.featuredimage -}}
|
|
{{- with .Resources.GetMatch "featured-image" -}}
|
|
{{- $image = .RelPermalink -}}
|
|
{{- end -}}
|
|
{{- with $image -}}
|
|
<div class="featured-image">
|
|
{{- dict "Src" . "Title" $.Description "Resources" $.Resources | partial "plugin/image.html" -}}
|
|
</div>
|
|
{{- end -}}
|
|
|
|
{{- /* Static TOC */ -}}
|
|
{{- if (ne $toc.enable false) | and (ne $tocEmpty true) -}}
|
|
<div class="details toc{{ with $params.password }} d-none{{ end }}" id="toc-static" data-kept="{{ if $toc.keepStatic }}true{{ else }}false{{ end }}">
|
|
<div class="details-summary toc-title">
|
|
<span>{{ T "single.contents" }}</span>
|
|
<span>{{ dict "Class" "details-icon fa-solid fa-angle-right" | partial "plugin/icon.html" }}</span>
|
|
</div>
|
|
<div class="details-content toc-content" id="toc-content-static">
|
|
{{- dict "Content" .TableOfContents "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
|
|
</div>
|
|
</div>
|
|
{{- end -}}
|
|
|
|
{{- /* Content */ -}}
|
|
{{- $content := dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
|
|
{{- if $params.password -}}
|
|
{{- $saltLen := strings.RuneCount (trim $params.password "") -}}
|
|
{{- $saltLen = cond (eq (mod $saltLen 2) 0) (add $saltLen 1) $saltLen -}}
|
|
{{- $base64EncodeContent := $content | base64Encode -}}
|
|
{{- $content = printf "%v%v%v"
|
|
(substr $base64EncodeContent 0 $saltLen)
|
|
(substr (sha256 $params.password) $saltLen)
|
|
(substr $base64EncodeContent $saltLen)
|
|
-}}
|
|
{{- end -}}
|
|
<div class="content" id="content"
|
|
{{- with $params.endFlag }} data-end-flag="{{ . }}"{{- end -}}
|
|
{{- with $params.password }} data-password="{{ md5 . }}"{{- end -}}
|
|
{{- with $params.password }} data-content="{{ $content }}"{{- end -}}
|
|
>
|
|
{{- if not $params.password -}}
|
|
{{- /* Expiration Reminder */ -}}
|
|
{{- partial "single/expiration-reminder.html" . -}}
|
|
{{- $content -}}
|
|
{{- else -}}
|
|
{{- partial "single/fixit-decryptor.html" . -}}
|
|
{{- end -}}
|
|
</div>
|
|
|
|
{{- /* Footer and Reward */ -}}
|
|
{{- $reward := .Scratch.Get "reward" -}}
|
|
{{- if eq $reward.position "before" -}}
|
|
{{- partial "single/reward.html" . -}}
|
|
{{- partial "single/footer.html" . -}}
|
|
{{- else -}}
|
|
{{- partial "single/footer.html" . -}}
|
|
{{- partial "single/reward.html" . -}}
|
|
{{- end -}}
|
|
|
|
{{- /* Comment */ -}}
|
|
{{- partial "single/comment.html" . -}}
|
|
</article>
|
|
{{- end -}}
|