summaryrefslogtreecommitdiff
path: root/layouts/_partials/posts/action-menu.html
diff options
context:
space:
mode:
authoreltrac <hi@eltr.ac>2026-03-14 17:36:52 +0800
committereltrac <hi@eltr.ac>2026-03-14 17:36:52 +0800
commit3cfe78392bb001d1dd81a184e8e083fb90eec656 (patch)
tree70519878ae578c7c5e7c5aedefd745b39e3bc821 /layouts/_partials/posts/action-menu.html
parent766a3c5ffeb83911c296e562bd1c95f90a803b7f (diff)
refactor(webmention): use new data format
Diffstat (limited to 'layouts/_partials/posts/action-menu.html')
-rw-r--r--layouts/_partials/posts/action-menu.html38
1 files changed, 30 insertions, 8 deletions
diff --git a/layouts/_partials/posts/action-menu.html b/layouts/_partials/posts/action-menu.html
index d3544c1f..fdb45596 100644
--- a/layouts/_partials/posts/action-menu.html
+++ b/layouts/_partials/posts/action-menu.html
@@ -1,27 +1,49 @@
-{{ $webmentions := index .Site.Data.webmentions .RelPermalink }}
+{{ $currentPagePath := .RelPermalink }}
+{{ $webmentions := slice }}
+
+{{ range .Site.Data.webmentions }}
+ {{/* 1. 解析数据中的绝对 URL */}}
+ {{ $urlObj := urls.Parse .webmention.target }}
+
+ {{/* 2. 获取其路径部分(例如 /posts/hello-world/) */}}
+ {{ $targetPath := $urlObj.Path }}
+
+ {{/* 3. 对比:考虑原始路径和编码后的路径 */}}
+ {{ if or (eq $targetPath $currentPagePath) (eq $targetPath ($currentPagePath | urlquery)) }}
+ {{ $webmentions = $webmentions | append . }}
+ {{ end }}
+{{ end }}
+
<!--
some pages were moved, merge their webmention with old Data
-->
-{{ $other_webmentions := index .Site.Data.webmentions (printf "/posts%s" .RelPermalink ) }}
+{{ $other_webmentions := where .Site.Data.webmentions "webmention.target" (printf "/posts%s" .RelPermalink ) }}
{{ if $other_webmentions }}
{{ $webmentions = $webmentions | union $other_webmentions }}
{{ end }}
{{ $likes := slice }}
{{ $replies := slice }}
+{{ $reposts := slice }}
{{ $mentions := slice }}
-{{ with $webmentions }}
-{{ range . }}
- {{ if eq .type "like-of" }}
+
+{{ range $webmentions }}
+ {{ $props := index . "microformats" "properties" }}
+
+ {{ if index $props "like-of" }}
{{ $likes = $likes | append . }}
- {{ else if eq .type "in-reply-to" }}
+
+ {{ else if index $props "in-reply-to" }}
{{ $replies = $replies | append . }}
- {{ else if eq .type "mention-of" }}
+
+ {{ else if index $props "repost-of" }}
+ {{ $reposts = $mentions | append . }}
+
+ {{ else }}
{{ $mentions = $mentions | append . }}
{{ end }}
{{ end }}
-{{ end }}
{{ partial "posts/action-area" . }}
<details class="my-4 mb-5 no-mark">