summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-11-26 16:46:15 +0800
committerEltrac <hi@guhub.cn>2025-11-26 16:46:15 +0800
commit3fef33e7be229620118b4cc967126f804e59a5cd (patch)
tree157f1442a20b094a8d239fe43c977039917b0481
parentbcfeb5371c9d6462806ffef4947b6af6798e91d5 (diff)
feat: site uptime count in sponsor page
-rw-r--r--content/sponsor.md2
-rw-r--r--layouts/_shortcodes/daysfrom.html12
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 -}}