summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-04-03 14:11:51 +0800
committerEltrac <hi@guhub.cn>2025-04-03 14:11:51 +0800
commitbb505f8fc86e47e277907437fd3240a58670759c (patch)
tree1472d3c85fb8ee82832430278d3b8d9676a5f8ea
parentc896f61fb6cc69b2cc65be3a5f5e28ddd2b90945 (diff)
feat: add sponsor page and link
-rw-r--r--content/sponsor.md15
-rw-r--r--layouts/_default/single.html3
-rw-r--r--layouts/shortcodes/postcount.html1
-rw-r--r--layouts/shortcodes/wordcount.html5
4 files changed, 24 insertions, 0 deletions
diff --git a/content/sponsor.md b/content/sponsor.md
new file mode 100644
index 00000000..2a2d9367
--- /dev/null
+++ b/content/sponsor.md
@@ -0,0 +1,15 @@
+---
+title: 赞助
+date: 2025-04-03 13:23:02
+draft: false
+---
+
+极客死亡计划上已经发布了 {{< postcount >}} 篇文章,共 {{< wordcount >}} 字。
+
+如果你觉得我的内容对你有帮助,可以考虑支持我,减轻我在域名续费和资源存储上的开销,以支持我继续创作和分享,同时也给我一些鼓励。你可以在赞助时留言,自 2025 年 4 月 3 日起的赞助者,名字和留言都会显示在这里。
+
+{{< img src="https://image.guhub.cn//uPic/IMG_3151-2.jpg" class="center small" >}}
+
+#### 赞助者名单
+
+<span style="font-size:90%">*还没有人赞助*</span>
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 2661bb11..e23acad0 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -48,6 +48,9 @@
{{ end }}
{{ .Site.Params.postHeaderContent | safeHTML }}
{{ .Content }}
+ {{ if and (eq .Site.Language.Lang "zh") (eq .Section "posts") }}
+ <p style="font-size: 0.9rem">如果你觉得文章对你有帮助,可以考虑<a href="/sponsor">赞助作者</a></p>
+ {{ end }}
</div>
{{ if in .Site.Params.mainSections .Type }}
diff --git a/layouts/shortcodes/postcount.html b/layouts/shortcodes/postcount.html
new file mode 100644
index 00000000..68da6893
--- /dev/null
+++ b/layouts/shortcodes/postcount.html
@@ -0,0 +1 @@
+{{ len (where .Site.RegularPages "Section" "posts") }}
diff --git a/layouts/shortcodes/wordcount.html b/layouts/shortcodes/wordcount.html
new file mode 100644
index 00000000..3b302b82
--- /dev/null
+++ b/layouts/shortcodes/wordcount.html
@@ -0,0 +1,5 @@
+{{ $total := 0 }}
+{{ range where .Site.RegularPages "Section" "posts" }}
+ {{ $total = add $total .WordCount }}
+{{ end }}
+{{ $total }}