Fix Mastodon/Bsky duplicate replies in webmentions.js
Build & Deploy / build-and-deploy (push) Successful in 2m1s

webmentions.js was adding NEW cards for Mastodon replies even when
Alpine had already rendered them, because the client-side filter didn't
mirror the Nunjucks build-time fed.brid.gy exclusion rule.

Pass mastodon-active + bsky-url as data attributes on the webmentions
container div, then filter out fed.brid.gy sourced Mastodon replies
and bsky.app/brid.gy/bluesky Bluesky replies from regularItems when
the corresponding Alpine component is active.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
svemagie
2026-04-20 19:20:16 +02:00
parent 0916b1e691
commit cf917a9010
2 changed files with 13 additions and 1 deletions
+2
View File
@@ -12,6 +12,8 @@
data-target="{{ absoluteUrl }}"
data-domain="{{ site.webmentions.domain }}"
data-buildtime="{{ buildTimestamp }}"
data-mastodon-active="{{ 'true' if mastodonInstance else '' }}"
data-bsky-url="{{ bskySyndUrl }}"
class="hidden"></div>
{# Detect Bluesky syndication URL here — needed to show section even without webmentions #}
+11 -1
View File
@@ -10,6 +10,8 @@
const target = container.dataset.target;
const domain = container.dataset.domain;
const buildTime = parseInt(container.dataset.buildtime, 10) || 0;
const mastodonActive = container.dataset.mastodonActive === 'true';
const bskyUrl = container.dataset.bskyUrl || '';
if (!target || !domain) return;
@@ -66,7 +68,15 @@
// Separate owner replies (threaded under parent) from regular interactions
var ownerReplies = allChildren.filter(function(wm) { return wm.is_owner && wm.parent_url; });
var regularItems = allChildren.filter(function(wm) { return !wm.is_owner && !isSelfBsky(wm); });
var regularItems = allChildren.filter(function(wm) {
if (wm.is_owner || isSelfBsky(wm)) return false;
var src = (wm['wm-source'] || '').toLowerCase();
var authorUrl = ((wm.author && wm.author.url) || '').toLowerCase();
// Mirror Nunjucks build-time filters: skip platform replies handled by Alpine
if (mastodonActive && src.includes('fed.brid.gy')) return false;
if (bskyUrl && (src.includes('bsky.app') || src.includes('brid.gy/bluesky') || authorUrl.includes('bsky.app'))) return false;
return true;
});
let mentionsToShow;
if (hasBuildTimeSection) {