Fix Mastodon/Bsky duplicate replies in webmentions.js
Build & Deploy / build-and-deploy (push) Successful in 2m1s
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:
@@ -12,6 +12,8 @@
|
|||||||
data-target="{{ absoluteUrl }}"
|
data-target="{{ absoluteUrl }}"
|
||||||
data-domain="{{ site.webmentions.domain }}"
|
data-domain="{{ site.webmentions.domain }}"
|
||||||
data-buildtime="{{ buildTimestamp }}"
|
data-buildtime="{{ buildTimestamp }}"
|
||||||
|
data-mastodon-active="{{ 'true' if mastodonInstance else '' }}"
|
||||||
|
data-bsky-url="{{ bskySyndUrl }}"
|
||||||
class="hidden"></div>
|
class="hidden"></div>
|
||||||
|
|
||||||
{# Detect Bluesky syndication URL here — needed to show section even without webmentions #}
|
{# Detect Bluesky syndication URL here — needed to show section even without webmentions #}
|
||||||
|
|||||||
+11
-1
@@ -10,6 +10,8 @@
|
|||||||
const target = container.dataset.target;
|
const target = container.dataset.target;
|
||||||
const domain = container.dataset.domain;
|
const domain = container.dataset.domain;
|
||||||
const buildTime = parseInt(container.dataset.buildtime, 10) || 0;
|
const buildTime = parseInt(container.dataset.buildtime, 10) || 0;
|
||||||
|
const mastodonActive = container.dataset.mastodonActive === 'true';
|
||||||
|
const bskyUrl = container.dataset.bskyUrl || '';
|
||||||
|
|
||||||
if (!target || !domain) return;
|
if (!target || !domain) return;
|
||||||
|
|
||||||
@@ -66,7 +68,15 @@
|
|||||||
|
|
||||||
// Separate owner replies (threaded under parent) from regular interactions
|
// Separate owner replies (threaded under parent) from regular interactions
|
||||||
var ownerReplies = allChildren.filter(function(wm) { return wm.is_owner && wm.parent_url; });
|
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;
|
let mentionsToShow;
|
||||||
if (hasBuildTimeSection) {
|
if (hasBuildTimeSection) {
|
||||||
|
|||||||
Reference in New Issue
Block a user