From 67585971c325bb4a000bcfd93a62a249a05a2501 Mon Sep 17 00:00:00 2001 From: svemagie Date: Mon, 20 Apr 2026 17:47:28 +0200 Subject: [PATCH] feat: merge Mastodon/AP thread replies into webmention Replies section --- _includes/components/webmentions.njk | 65 ++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/_includes/components/webmentions.njk b/_includes/components/webmentions.njk index a43f65f..0ccb156 100644 --- a/_includes/components/webmentions.njk +++ b/_includes/components/webmentions.njk @@ -110,28 +110,45 @@ {% endif %} - {# Replies — webmention replies merged with Bluesky thread (deduplicated) #} + {# Replies — webmention replies merged with Bluesky + Mastodon/AP threads (deduplicated) #} {% set wm_replies = mentions | webmentionsByType('replies') %} + + {# Detect Bluesky syndication URL #} {% set bskySyndUrl = "" %} {% if syndication %} {% for url in syndication %} {% if "bsky.app" in url %}{% set bskySyndUrl = url %}{% endif %} {% endfor %} {% endif %} - {# Filter out Bluesky-sourced webmention replies when a direct thread is available #} + + {# Detect Mastodon/AP activity: check if any webmention reply came via fed.brid.gy #} + {% set mastodonInstance = site.feeds.mastodon.instance %} + {% set apIdentity = site.fediverseCreator %} + {% set hasApReplies = false %} + {% for reply in wm_replies %} + {% if 'fed.brid.gy' in reply['wm-source'] | default('') %}{% set hasApReplies = true %}{% endif %} + {% endfor %} + {% set mastodonActive = mastodonInstance and hasApReplies %} + {% set replyComponentActive = bskySyndUrl or mastodonActive %} + + {# Filter: remove Bluesky-sourced webmentions if bskySyndUrl; remove fed.brid.gy webmentions if mastodonActive #} {% set filtered_replies = [] %} {% for reply in wm_replies %} {% set src = reply['wm-source'] | default('') %} - {% if not bskySyndUrl or ('bsky.app' not in src and 'brid.gy' not in src and 'bridgy' not in src) %} + {% set includeReply = true %} + {% if bskySyndUrl and ('bsky.app' in src or 'brid.gy' in src or 'bridgy' in src) %}{% set includeReply = false %}{% endif %} + {% if mastodonActive and 'fed.brid.gy' in src %}{% set includeReply = false %}{% endif %} + {% if includeReply %} {% set filtered_replies = (filtered_replies.push(reply), filtered_replies) %} {% endif %} {% endfor %} - {% if filtered_replies.length or bskySyndUrl %} -
- {% set wmRepliesCount = filtered_replies.length %} + + {% if filtered_replies.length or replyComponentActive %} + {% set wmRepliesCount = filtered_replies.length %} +

- {% if not bskySyndUrl %}{{ wmRepliesCount }} Repl{% if wmRepliesCount != 1 %}ies{% else %}y{% endif %}{% endif %} + {% if replyComponentActive %}x-text="({{ wmRepliesCount }} + bskyReplies.length + mastodonReplies.length) + ' Repl' + (({{ wmRepliesCount }} + bskyReplies.length + mastodonReplies.length !== 1) ? 'ies' : 'y')"{% endif %}> + {% if not replyComponentActive %}{{ wmRepliesCount }} Repl{% if wmRepliesCount != 1 %}ies{% else %}y{% endif %}{% endif %}

    {% for reply in filtered_replies %} @@ -190,7 +207,7 @@ {% endfor %} {% if bskySyndUrl %} -