From 3b1d708c6d8e7eb2c46d50e7a97dbf5bf8b3bc3c Mon Sep 17 00:00:00 2001 From: Eltrac Date: Thu, 29 May 2025 16:16:33 +0800 Subject: feat(post): add fuzzy time after date Former-commit-id: 2f6ef0c21dcf62d404a5b031e8eb39511631d667 --- layouts/posts/single.html | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'layouts/posts/single.html') diff --git a/layouts/posts/single.html b/layouts/posts/single.html index c08b7944..3fe80a84 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -20,11 +20,33 @@
{{ if .Date }} - + {{ $hour := .Date.Hour }} + {{ $fuzzyTime := "" }} + {{ if lt $hour 5 }} + {{ $fuzzyTime = "凌晨" }} + {{ else if lt $hour 7 }} + {{ $fuzzyTime = "清晨" }} + {{ else if lt $hour 11 }} + {{ $fuzzyTime = "早上" }} + {{ else if lt $hour 13 }} + {{ $fuzzyTime = "中午" }} + {{ else if lt $hour 17 }} + {{ $fuzzyTime = "下午" }} + {{ else if lt $hour 19 }} + {{ $fuzzyTime = "傍晚" }} + {{ else if lt $hour 23 }} + {{ $fuzzyTime = "晚上" }} + {{ else }} + {{ $fuzzyTime = "深夜" }} + {{ end }} + + {{ end }} + {{ if or .Params.categories .Params.tags }} · + {{ end }} {{ if .Params.categories }} {{ end }} -- cgit v1.2.3