summaryrefslogtreecommitdiff
path: root/layouts/_partials/components/date.html
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-07-14 19:26:28 +0800
committerEltrac <hi@guhub.cn>2025-07-14 19:26:28 +0800
commit29af8b6c2bd89c1966512b4305af345b8ee1ef82 (patch)
tree07a4801791db7d6a4670d53411f0689ec0090bfe /layouts/_partials/components/date.html
parent44c7def3f6958550ccf965971f1819c1d6c514f1 (diff)
refactor: clearer division of each partial and better folder structure
Diffstat (limited to 'layouts/_partials/components/date.html')
-rw-r--r--layouts/_partials/components/date.html26
1 files changed, 26 insertions, 0 deletions
diff --git a/layouts/_partials/components/date.html b/layouts/_partials/components/date.html
new file mode 100644
index 00000000..1998202f
--- /dev/null
+++ b/layouts/_partials/components/date.html
@@ -0,0 +1,26 @@
+{{ 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 }}