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 %} -