diff options
| author | Eltrac <hi@guhub.cn> | 2025-07-14 19:26:28 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-07-14 19:26:28 +0800 |
| commit | 29af8b6c2bd89c1966512b4305af345b8ee1ef82 (patch) | |
| tree | 07a4801791db7d6a4670d53411f0689ec0090bfe /layouts/_partials/components/date.html | |
| parent | 44c7def3f6958550ccf965971f1819c1d6c514f1 (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.html | 26 |
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 }} |
