mirror of
https://github.com/svemagie/blog-eleventy-indiekit.git
synced 2026-04-02 16:44:56 +02:00
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.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user