From 3971379b39c8c194bf2e736d88307c57028beb6b Mon Sep 17 00:00:00 2001 From: BigCoke233 Date: Wed, 17 Dec 2025 12:02:49 +0800 Subject: feat: add webmention to action menu Former-commit-id: dd27c7bfb5932d8402b1f89984196f8566c14d5e --- assets/css/_webmention.scss | 17 +++++++ i18n/en.yml | 2 + i18n/zh.yml | 2 + layouts/_partials/components/toggle-button.html | 53 ++++++++++++++++++++++ layouts/_partials/posts/action-menu.html | 2 + .../posts/action-menu/comment-button.html | 41 +++-------------- .../posts/action-menu/webmention-button.html | 16 +++++++ .../posts/action-menu/webmention-section.html | 8 ++++ layouts/_partials/posts/comment.html | 3 -- static/img/mention.svg | 37 +++++++++++++++ 10 files changed, 143 insertions(+), 38 deletions(-) create mode 100644 assets/css/_webmention.scss create mode 100644 layouts/_partials/components/toggle-button.html create mode 100644 layouts/_partials/posts/action-menu/webmention-button.html create mode 100644 layouts/_partials/posts/action-menu/webmention-section.html create mode 100644 static/img/mention.svg diff --git a/assets/css/_webmention.scss b/assets/css/_webmention.scss new file mode 100644 index 00000000..4f5d861a --- /dev/null +++ b/assets/css/_webmention.scss @@ -0,0 +1,17 @@ +#webmentions { + .comments { + list-style: none; + padding-inline-start: 0; + li { + display: flex; + align-items: center; + .reaction { + img { + height: 2rem; + width: 2rem; + border-radius: 50%; + } + } + } + } +} diff --git a/i18n/en.yml b/i18n/en.yml index 17a12af8..f22eabc5 100644 --- a/i18n/en.yml +++ b/i18n/en.yml @@ -57,3 +57,5 @@ actionMenu: like: Sacrifice your heart liked: You've already made your sacrifice rss_comment_link: "Come and leave a comment" +webmention: + fetching: Fetching Webmention... diff --git a/i18n/zh.yml b/i18n/zh.yml index 3ec0151b..991798ac 100644 --- a/i18n/zh.yml +++ b/i18n/zh.yml @@ -56,3 +56,5 @@ actionMenu: like: 为这篇文章献上心脏 liked: 你已经献上心脏了 rss_comment_link: "读完啦?来坐坐吧" +webmention: + fetching: 正在获取 Webmention... diff --git a/layouts/_partials/components/toggle-button.html b/layouts/_partials/components/toggle-button.html new file mode 100644 index 00000000..3aef1509 --- /dev/null +++ b/layouts/_partials/components/toggle-button.html @@ -0,0 +1,53 @@ +{{/* + Reusable Toggle Button Component + + Parameters: + - id: (string) Unique identifier for the button group (e.g. "comments"). + Used to generate IDs: {id}-toggle, {id}-section, {id}-count. + - title: (string) Tooltip title. + - icon: (string) Path to the icon image. + - countId: (string, optional) Override for count element ID. Defaults to "{id}-count". + - sectionId: (string, optional) Override for section element ID. Defaults to "{id}-section". + - buttonId: (string, optional) Override for button element ID. Defaults to "{id}-toggle". +*/}} +{{ $id := .id }} +{{ $buttonId := default (printf "%s-toggle" $id) .buttonId }} +{{ $sectionId := default (printf "%s-section" $id) .sectionId }} +{{ $countId := default (printf "%s-count" $id) .countId }} + + + + diff --git a/layouts/_partials/posts/action-menu.html b/layouts/_partials/posts/action-menu.html index ae19873a..cc5aca46 100644 --- a/layouts/_partials/posts/action-menu.html +++ b/layouts/_partials/posts/action-menu.html @@ -3,10 +3,12 @@
{{ partial "posts/action-menu/comment-button" . }} + {{ partial "posts/action-menu/webmention-button" . }} {{ partial "posts/action-menu/like-button" . }}
{{ partial "posts/action-menu/info-links" . }}
{{ partial "posts/action-menu/comment-section" . }} + {{ partial "posts/action-menu/webmention-section" . }} diff --git a/layouts/_partials/posts/action-menu/comment-button.html b/layouts/_partials/posts/action-menu/comment-button.html index d646ca27..cd6fe33b 100644 --- a/layouts/_partials/posts/action-menu/comment-button.html +++ b/layouts/_partials/posts/action-menu/comment-button.html @@ -1,42 +1,14 @@ - +{{ partial "components/toggle-button.html" (dict + "id" "comments" + "title" (T "actionMenu.comment") + "icon" "/img/comments.svg" + "countId" "comment-count" +) }} diff --git a/layouts/_partials/posts/action-menu/webmention-button.html b/layouts/_partials/posts/action-menu/webmention-button.html new file mode 100644 index 00000000..b447090a --- /dev/null +++ b/layouts/_partials/posts/action-menu/webmention-button.html @@ -0,0 +1,16 @@ +{{ partial "components/toggle-button.html" (dict + "id" "webmention" + "title" (T "actionMenu.comment") + "icon" "/img/mention.svg" + "countId" "mention-count" +) }} + + diff --git a/layouts/_partials/posts/action-menu/webmention-section.html b/layouts/_partials/posts/action-menu/webmention-section.html new file mode 100644 index 00000000..5d726aff --- /dev/null +++ b/layouts/_partials/posts/action-menu/webmention-section.html @@ -0,0 +1,8 @@ + +
+ +
diff --git a/layouts/_partials/posts/comment.html b/layouts/_partials/posts/comment.html index d05ff2d4..6e959f49 100644 --- a/layouts/_partials/posts/comment.html +++ b/layouts/_partials/posts/comment.html @@ -33,9 +33,6 @@

- -
-