From e23457681ab611c782d2fbf841e0edf144c764ae Mon Sep 17 00:00:00 2001 From: eltrac Date: Sat, 14 Mar 2026 19:13:40 +0800 Subject: 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) --- layouts/_partials/posts/action-menu.html | 7 ++----- 1 file 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 }} -- cgit v1.2.3