From a73e0b8439763fca242322d228ead3c800504ced Mon Sep 17 00:00:00 2001 From: BigCoke233 Date: Sat, 31 Jan 2026 00:57:07 +0800 Subject: feat: new comment area --- layouts/_partials/components/toggle-button.html | 69 ------------ layouts/_partials/posts/action-menu.html | 34 ++++-- .../posts/action-menu/comment-button.html | 7 -- .../posts/action-menu/comment-section.html | 6 - .../_partials/posts/action-menu/info-links.html | 11 -- .../posts/action-menu/webmention-button.html | 13 --- .../posts/action-menu/webmention-section.html | 122 --------------------- layouts/_partials/posts/comment.html | 43 ++++---- layouts/_partials/posts/webmention-likes.html | 20 ++++ layouts/_partials/posts/webmention-mentions.html | 14 +++ layouts/_partials/posts/webmention-replies.html | 23 ++++ 11 files changed, 98 insertions(+), 264 deletions(-) delete mode 100644 layouts/_partials/components/toggle-button.html delete mode 100644 layouts/_partials/posts/action-menu/comment-button.html delete mode 100644 layouts/_partials/posts/action-menu/comment-section.html delete mode 100644 layouts/_partials/posts/action-menu/info-links.html delete mode 100644 layouts/_partials/posts/action-menu/webmention-button.html delete mode 100644 layouts/_partials/posts/action-menu/webmention-section.html create mode 100644 layouts/_partials/posts/webmention-likes.html create mode 100644 layouts/_partials/posts/webmention-mentions.html create mode 100644 layouts/_partials/posts/webmention-replies.html diff --git a/layouts/_partials/components/toggle-button.html b/layouts/_partials/components/toggle-button.html deleted file mode 100644 index edc0e930..00000000 --- a/layouts/_partials/components/toggle-button.html +++ /dev/null @@ -1,69 +0,0 @@ -{{ $id := .id }} -{{ $buttonId := default (printf "%s-toggle" $id) .buttonId }} -{{ $sectionId := default (printf "%s-section" $id) .sectionId }} -{{ $countId := default (printf "%s-count" $id) .countId }} -{{ $count := default "0" .count }} -{{ $group := .group }} - - - - diff --git a/layouts/_partials/posts/action-menu.html b/layouts/_partials/posts/action-menu.html index ab4c87d5..afab7663 100644 --- a/layouts/_partials/posts/action-menu.html +++ b/layouts/_partials/posts/action-menu.html @@ -1,14 +1,24 @@ +{{ $webmentions := index .Site.Data.webmentions .RelPermalink }} +{{ $likes := slice }} +{{ $replies := slice }} +{{ $mentions := slice }} +{{ with $webmentions }} +{{ range . }} + {{ if eq .type "like-of" }} + {{ $likes = $likes | append . }} + {{ else if eq .type "in-reply-to" }} + {{ $replies = $replies | append . }} + {{ else if eq .type "mention-of" }} + {{ $mentions = $mentions | append . }} + {{ end }} +{{ end }} +{{ end }} +
- -
-
- {{ partial "posts/action-menu/comment-button" . }} - {{ partial "posts/action-menu/webmention-button" . }} -
- {{ partial "posts/action-menu/info-links" . }} -
-
- {{ partial "posts/action-menu/comment-section" . }} - {{ partial "posts/action-menu/webmention-section" . }} -
+ {{ partial "posts/webmention-likes" $likes }} + {{ partial "posts/webmention-replies" $replies }} + {{ partial "posts/webmention-mentions" $mentions }} + + + {{ partial "posts/comment" . }}
diff --git a/layouts/_partials/posts/action-menu/comment-button.html b/layouts/_partials/posts/action-menu/comment-button.html deleted file mode 100644 index 8ad02ae0..00000000 --- a/layouts/_partials/posts/action-menu/comment-button.html +++ /dev/null @@ -1,7 +0,0 @@ -{{ partial "components/toggle-button.html" (dict - "id" "comments" - "title" (T "actionMenu.comment") - "icon" "/img/comments.svg" - "countId" "comment-count" - "group" "action-menu-section" -) }} diff --git a/layouts/_partials/posts/action-menu/comment-section.html b/layouts/_partials/posts/action-menu/comment-section.html deleted file mode 100644 index d5909597..00000000 --- a/layouts/_partials/posts/action-menu/comment-section.html +++ /dev/null @@ -1,6 +0,0 @@ - -
- -
diff --git a/layouts/_partials/posts/action-menu/info-links.html b/layouts/_partials/posts/action-menu/info-links.html deleted file mode 100644 index 46042344..00000000 --- a/layouts/_partials/posts/action-menu/info-links.html +++ /dev/null @@ -1,11 +0,0 @@ -{{ if eq .Site.Language.Lang "zh" }} -
- - {{ T - -
-{{ end }} diff --git a/layouts/_partials/posts/action-menu/webmention-button.html b/layouts/_partials/posts/action-menu/webmention-button.html deleted file mode 100644 index aba5891f..00000000 --- a/layouts/_partials/posts/action-menu/webmention-button.html +++ /dev/null @@ -1,13 +0,0 @@ -{{ $webmentions := index .Site.Data.webmentions .RelPermalink }} -{{ $count := 0 }} -{{ with $webmentions }} - {{ $count = len $webmentions }} -{{ end }} -{{ partial "components/toggle-button.html" (dict - "id" "webmention" - "title" (T "actionMenu.webmention") - "icon" "/img/mention.svg" - "countId" "mention-count" - "count" $count - "group" "action-menu-section" -) }} diff --git a/layouts/_partials/posts/action-menu/webmention-section.html b/layouts/_partials/posts/action-menu/webmention-section.html deleted file mode 100644 index fa952e9c..00000000 --- a/layouts/_partials/posts/action-menu/webmention-section.html +++ /dev/null @@ -1,122 +0,0 @@ - -
- -
diff --git a/layouts/_partials/posts/comment.html b/layouts/_partials/posts/comment.html index e4ec9b3e..bcd0b17b 100644 --- a/layouts/_partials/posts/comment.html +++ b/layouts/_partials/posts/comment.html @@ -1,8 +1,3 @@ - -

- *{{ T "emailMe" }} {{ .Site.Params.email }} -

- {{ $cutoffDate := time.AsTime "2026-01-30" }} {{ if .Params.Date.Before $cutoffDate }} - -

博客的评论区已经被禁用,旧的数据已经导出,如果存在,就会显示在下方。如果你想要讨论此文,可以邮件联系,或者在联邦宇宙上互动。

- -
- {{ $giscusData := .Site.Data.giscus }} {{ $pageTitle := .Title }} {{ range $giscusData }} {{ if eq .title $pageTitle }} + {{ $url := .url }} {{ with .comments.nodes }} -
- {{ range . }} -
-
- {{ .author.login }} - {{ .createdAt | time.Format "2006/01/02" }} +
+ 博客的评论区已经被禁用,旧的数据已经导出,可以点击这行字查看。 +
+ {{ range . }} +
+
+ {{ .author.login }} + {{ .createdAt | time.Format "2006/01/02" }} +
+
+ {{ .body | markdownify }} +
-
- {{ .body | markdownify }} -
-
+ {{ end }} +
+ {{ with $url }} +

Full GitHub Discussion →

{{ end }} -
- {{ end }} - {{ with .url }} -

Full GitHub Discussion →

+
+ {{ end }} {{ end }} {{ end }} diff --git a/layouts/_partials/posts/webmention-likes.html b/layouts/_partials/posts/webmention-likes.html new file mode 100644 index 00000000..7169a655 --- /dev/null +++ b/layouts/_partials/posts/webmention-likes.html @@ -0,0 +1,20 @@ +{{ with . }} +
+ +

{{ printf (T "webmention.likedBy") (len . ) }}

+
+{{ end }} + diff --git a/layouts/_partials/posts/webmention-mentions.html b/layouts/_partials/posts/webmention-mentions.html new file mode 100644 index 00000000..2a133d0b --- /dev/null +++ b/layouts/_partials/posts/webmention-mentions.html @@ -0,0 +1,14 @@ +{{ with . }} +
+

{{ T "webmention.mentionsHeading" . }}

+{{ range . }} +
    + {{ with .content }} +
  • {{ .html | safeHTML }}
  • + {{ else }} +
  • {{ .url }}
  • + {{ end }} +
+{{ end }} +
+{{ end }} diff --git a/layouts/_partials/posts/webmention-replies.html b/layouts/_partials/posts/webmention-replies.html new file mode 100644 index 00000000..570a0e4d --- /dev/null +++ b/layouts/_partials/posts/webmention-replies.html @@ -0,0 +1,23 @@ +{{ with . }} +
+{{ range . }} +
+
+ Profile Picture +
+

+ + {{ .author.name }} + +

+ {{ $t := time.AsTime .received }} +

+
+
+
{{ .content.html | safeHTML }}
+
+{{ end }} +
+
+{{ end }} -- cgit v1.2.3