Files
FixIt/layouts/posts/single.html
T

165 lines
8.2 KiB
HTML

{{- 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 "contents" }} <i class="toc-icon fa-solid fa-angle-down fa-fw"></i></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 -->
</aside>
<article class="page single">
<div class="header">
{{- /* Title */ -}}
<h1 class="single-title animate__animated animate__flipInX">{{ .Title }}</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"><i class="fa-regular fa-folder fa-fw"></i>&nbsp;%v</a>` $category.RelPermalink $category.Title) -}}
{{- end -}}
{{- with delimit $categories "&ensp;" }}
<span class="post-category">
{{- dict "Categories" . | T "includedInCategories" | safeHTML -}}
</span>
{{- end -}}
</div>
<div class="post-meta-line">
{{- with .Site.Params.dateformat | default "2006-01-02" | .PublishDate.Format -}}
<span title={{ "2006-01-02 15:04:05" | $.PublishDate.Format }}>
<i class="fa-regular fa-calendar-alt fa-fw"></i>&nbsp;<time datetime="{{ . }}" >{{ . }}</time>
</span>&nbsp;
{{- end -}}
<i class="fa-solid fa-pencil-alt fa-fw"></i>&nbsp;{{ T "wordCount" .WordCount }}&nbsp;
<i class="fa-regular fa-clock fa-fw"></i>&nbsp;{{ T "readingTime" .ReadingTime }}&nbsp;
{{- /* 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 "comment" (dict "enable" false) -}}
{{- end -}}
{{- $comment := .Scratch.Get "comment" | default dict -}}
{{- /* Visitor Count */ -}}
{{- if $comment.enable -}}
{{- if ($comment.valine.enable | and $comment.valine.visitor) | or ($comment.waline.enable | and $comment.waline.visitor) -}}
{{- /* Warning: waline v2 will not be compatible with valine */ -}}
<span id="{{ .RelPermalink }}" class="leancloud_visitors comment-visitors" data-flag-title="{{ .Title }}">
<i class="fa-regular fa-eye fa-fw"></i>&nbsp;<span class="leancloud-visitors-count">-</span>&nbsp;{{ T "views" }}
</span>&nbsp;
{{- else if $comment.waline.enable | and $comment.waline.visitor -}}
<span class="comment-visitors" data-flag-title="{{ .Title }}">
<i class="fa-regular fa-eye fa-fw"></i>&nbsp;<span id="{{ .RelPermalink }}" class="waline-visitor-count">-</span>&nbsp;{{ T "views" }}
</span>&nbsp;
{{- else if $comment.twikoo.enable | and $comment.twikoo.visitor -}}
<span id="{{ .RelPermalink }}" class="comment-visitors" data-flag-title="{{ .Title }}">
<i class="fa-regular fa-eye fa-fw"></i>&nbsp;<span id="twikoo_visitors">-</span>&nbsp;{{ T "views" }}
</span>&nbsp;
{{- 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 }}">
<i class="fa-regular fa-eye fa-fw"></i>&nbsp;<span id="busuanzi_value_page_pv">-</span>&nbsp;{{ T "views" }}
</span>&nbsp;
{{- 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 }}">
<i class="fa-regular fa-eye fa-fw"></i>&nbsp;<span id="busuanzi_value_page_pv">-</span>&nbsp;{{ T "views" }}
</span>&nbsp;
{{- end -}}
{{- /* Comment Count */ -}}
{{- if $comment.enable -}}
{{- if $comment.valine.enable | and $comment.valine.commentCount -}}
<span class="comment-count" data-flag-title="{{ .Title }}">
<i class="fa-regular fa-comments fa-fw"></i>&nbsp;<span data-xid="{{ .RelPermalink }}" class="valine-comment-count">-</span>&nbsp;{{ T "comments" }}
</span>&nbsp;
{{- else if $comment.waline.enable | and $comment.waline.commentCount -}}
<span class="comment-count" data-flag-title="{{ .Title }}">
<i class="fa-regular fa-comments fa-fw"></i>&nbsp;<span id="{{ .RelPermalink }}" class="waline-comment-count">-</span>&nbsp;{{ T "comments" }}
</span>&nbsp;
{{- else if $comment.twikoo.enable | and $comment.twikoo.commentCount -}}
<span id="{{ .RelPermalink }}" class="comment-count" data-flag-title="{{ .Title }}">
<i class="fa-regular fa-comments fa-fw"></i>&nbsp;<span id="twikoo-comment-count">-</span>&nbsp;{{ T "comments" }}
</span>&nbsp;
{{- 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" kept="{{ if $toc.keepStatic }}true{{ else }}false{{ end }}">
<div class="details-summary toc-title">
<span>{{ T "contents" }}</span>
<span><i class="details-icon fa-solid fa-angle-right"></i></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.password }}data-password="{{ md5 $params.password }}"{{ 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 */ -}}
{{- partial "single/footer.html" . -}}
{{- /* Comment */ -}}
{{- partial "single/comment.html" . -}}
</article>
{{- end -}}