diff options
| author | Eltrac <hi@guhub.cn> | 2025-06-06 14:53:45 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-06-06 14:53:45 +0800 |
| commit | 9855baa4d1dea96fc4516283bf66a98f10a29eaa (patch) | |
| tree | 6a6fefb50c40489c439552ab1fcd4c0beb94c34d /layouts/posts/single.html | |
| parent | b95d3e0b2b90bbb6235da81e84b6eefc63ee1da1 (diff) | |
refactor: reuse some page components
Former-commit-id: ed5fe0848d18665cd3fbd6011876207b2fee61e4
Diffstat (limited to 'layouts/posts/single.html')
| -rw-r--r-- | layouts/posts/single.html | 73 |
1 files changed, 8 insertions, 65 deletions
diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 71716a82..86d595d6 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -16,38 +16,9 @@ </h1> <!-- Post Meta --> <div class="post-meta"> - {{ if .Date }} - {{ $hour := .Date.Hour }} - {{ $fuzzyTimes := slice - (dict "limit" 5 "label" "凌晨") - (dict "limit" 7 "label" "清晨") - (dict "limit" 11 "label" "早上") - (dict "limit" 13 "label" "中午") - (dict "limit" 17 "label" "下午") - (dict "limit" 19 "label" "傍晚") - (dict "limit" 22 "label" "晚上") - }} - {{ $fuzzyTime := "深夜" }} {{/* default */}} - {{ range $fuzzyTimes }} - {{ if lt $hour .limit }} - {{ $fuzzyTime = .label }} - {{ break }} - {{ end }} - {{ end }} - - <time class="post-date" - datetime="{{ .Date.Format "2006-01-02 15:04:05 MST" }}" - data-pagefind-sort="date[datetime], weight[data-weight]" - data-weight="{{ if .Params.featured }}30{{ else }}20{{ end }}"> - {{ .Date.Format "2006年1月2日" }} {{ $fuzzyTime }} - </time> - {{ end }} - {{ if or .Params.categories .Params.tags }} - <span>·</span> - {{ end }} - {{ if .Params.categories }} - <a class="post-category" href="/categories/{{ .Params.categories | urlize }}">{{ .Params.categories }}</a> - {{ end }} + {{ partial "components/date" . }} + {{ if or .Params.categories .Params.tags }}<span>·</span>{{ end }} + {{ partial "components/category-pill" . }} {{ range .Params.tags }} <a class="post-tag" href="{{ site.LanguagePrefix }}/tags/{{ lower . | urlize }}/">#{{ . }}</a> {{ end }} @@ -58,46 +29,18 @@ <div class="post-content markdown-body" style="view-transition-name: post-content-{{ .File.UniqueID }}"> <!-- TOC --> - {{ if .Params.toc }} {{ partial "components/toc" . }} - {{ end }} <!-- Content --> - <div id="post-content">{{ .Content }}</div> - <!-- Endnotes --> - {{ if .Params.endnotes }} - <hr> - <div id="post-endnotes"> - <ul> - {{ range .Params.endnotes }} - <li>{{ . | markdownify }}</li> - {{ end }} - </ul> + <div id="post-content"> + {{ .Content }} </div> - {{ end }} + <!-- Endnotes --> + {{ partial "components/endnotes" . }} </div> <!-- Comment --> {{ partial "components/comment.html" . }} - <!-- Now Read This --> - {{ with site.RegularPages.Related . | first 1 }} - <div class="nrt post-content"> - <h4 class="nrt-title">{{ T "nowReadThis" }}</h4> - {{ range . }} - <div class="nrt-header"> - <a class="nrt-link" href="{{ .RelPermalink }}" data-umami-event="🤔 Click Related Post"> - {{ .LinkTitle }} - {{ with .Params.subtitle }} - <span class="nrt-subtitle">:{{ . }}</span> - {{ end }} - </a> - <span class="nrt-reading-time">⏱️ {{ .ReadingTime }}min </span> - </div> - <div class="nrt-summary"> - <p>{{ .Summary | plainify }}</p> - </div> - {{ end }} - </div> - {{ end }} + {{ partial "components/now-read-this.html" . }} </article> {{ end }} |
