From a7bc472e874d42a1ecfa885910c675edb9ab99cc Mon Sep 17 00:00:00 2001 From: Ricardo Date: Mon, 23 Feb 2026 10:06:19 +0100 Subject: [PATCH] fix: deduplicate cross-source webmentions webmention.io cache and conversations API can report the same interaction (e.g. a like) with different wm-id formats. Deduplicate by author URL + interaction type after URL filtering to prevent the same like/reply appearing twice. --- eleventy.config.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/eleventy.config.js b/eleventy.config.js index dd1555c..ec2f363 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -484,7 +484,21 @@ export default function (eleventyConfig) { } // Filter merged data matching any of our URLs - return merged.filter((wm) => urlsToCheck.has(wm["wm-target"])); + const matched = merged.filter((wm) => urlsToCheck.has(wm["wm-target"])); + + // Deduplicate cross-source: same author + same interaction type = same mention + // (webmention.io and conversations API may both report the same like/reply) + const deduped = []; + const authorActions = new Set(); + for (const wm of matched) { + const authorUrl = wm.author?.url || wm.url || ""; + const action = wm["wm-property"] || "mention"; + const key = `${authorUrl}::${action}`; + if (authorActions.has(key)) continue; + authorActions.add(key); + deduped.push(wm); + } + return deduped; }); eleventyConfig.addFilter("webmentionsByType", function (mentions, type) {