fix: remove duplicate mastodon webmention cards client-side
Build & Deploy / build-and-deploy (push) Successful in 2m1s
Build & Deploy / build-and-deploy (push) Successful in 2m1s
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.
This commit is contained in:
@@ -97,6 +97,13 @@ document.addEventListener("alpine:init", () => {
|
|||||||
published: s.created_at,
|
published: s.created_at,
|
||||||
favourites: s.favourites_count || 0,
|
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 {
|
} catch {
|
||||||
// fail silently
|
// fail silently
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user