summaryrefslogtreecommitdiff
path: root/layouts/_partials/posts
diff options
context:
space:
mode:
authoreltrac <hi@eltr.ac>2026-03-14 19:13:40 +0800
committereltrac <hi@eltr.ac>2026-03-14 19:13:40 +0800
commite23457681ab611c782d2fbf841e0edf144c764ae (patch)
treeadde09a60bb77547aa35391d6b4f30342f8da956 /layouts/_partials/posts
parentae3f800be029c775ff042f10e85519f0e87cc1ad (diff)
feat: fuzzy webmention matching
use `Contains` instead of `eq` (equal), to include posts affected by url change (/posts/weekly/xx -> /weekly/xx) and to include webmention sent to url with anchor (/article/xxx#heading)
Diffstat (limited to 'layouts/_partials/posts')
-rw-r--r--layouts/_partials/posts/action-menu.html7
1 files changed, 2 insertions, 5 deletions
diff --git a/layouts/_partials/posts/action-menu.html b/layouts/_partials/posts/action-menu.html
index fdb45596..869996b9 100644
--- a/layouts/_partials/posts/action-menu.html
+++ b/layouts/_partials/posts/action-menu.html
@@ -2,14 +2,11 @@
{{ $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)) }}
+ {{ if or (strings.Contains $targetPath $currentPagePath)
+ (strings.Contains $targetPath ($currentPagePath | urlquery)) }}
{{ $webmentions = $webmentions | append . }}
{{ end }}
{{ end }}