From c13eddacb1c5502143bb41f1153d7d6318b253d8 Mon Sep 17 00:00:00 2001 From: svemagie <869694+svemagie@users.noreply.github.com> Date: Mon, 20 Apr 2026 18:28:08 +0200 Subject: [PATCH] fix: remove duplicate mastodon webmention cards client-side MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build-time Nunjucks filter only removes static webmentions. Client-side webmention fetcher (webmentions.js) adds NEW cards after page load, bypassing the filter. After mastodon replies load, remove any li[data-author-url] cards whose author URL matches a mastodon reply — keeing the richer Alpine card. --- js/social-threads.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/social-threads.js b/js/social-threads.js index 1a84836..9756522 100644 --- a/js/social-threads.js +++ b/js/social-threads.js @@ -97,6 +97,13 @@ document.addEventListener("alpine:init", () => { published: s.created_at, favourites: s.favourites_count || 0, })); + + // Remove webmention cards (build-time or client-fetched) that duplicate mastodon replies. + // Webmention cards have data-author-url; Alpine x-for cards do not. + const mastodonAuthorUrls = new Set(this.mastodonReplies.map((r) => r.author.url)); + document.querySelectorAll(".webmention-replies li[data-author-url]").forEach((li) => { + if (mastodonAuthorUrls.has(li.dataset.authorUrl)) li.remove(); + }); } catch { // fail silently }