diff options
| -rw-r--r-- | content/sponsor.md | 2 | ||||
| -rw-r--r-- | layouts/_shortcodes/daysfrom.html | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/content/sponsor.md b/content/sponsor.md index b0da3024..a6a12791 100644 --- a/content/sponsor.md +++ b/content/sponsor.md @@ -4,7 +4,7 @@ date: 2025-04-03 13:23:02 draft: false --- -极客死亡计划上已经发布了 {{< postcount >}} 篇文章,共 {{< wordcount >}} 字。 +极客死亡计划已经运行了 {{< daysfrom "2024-07-28" >}} 天,发布了 {{< postcount >}} 篇文章,共 {{< wordcount >}} 字。 如果你觉得我的内容对你有帮助,可以考虑支持我,减轻我在域名续费和资源存储上的开销,以支持我继续创作和分享,同时也给我一些鼓励。你可以在赞助时留言,自 2025 年 4 月 3 日起的赞助者,名字和留言都会显示在这里。[^1] diff --git a/layouts/_shortcodes/daysfrom.html b/layouts/_shortcodes/daysfrom.html new file mode 100644 index 00000000..c2750480 --- /dev/null +++ b/layouts/_shortcodes/daysfrom.html @@ -0,0 +1,12 @@ +{{- $date := .Get 0 -}} +{{- $t := time $date -}} +{{- $now := now -}} +{{- $durSeconds := sub $now.Unix $t.Unix | int -}} + +{{- $days := div $durSeconds 86400 -}} + +{{- if lt $days 0 -}} + {{ mul $days -1 }} +{{- else -}} + {{ $days }} +{{- end -}} |
