mirror of
https://github.com/svemagie/blog-eleventy-indiekit.git
synced 2026-04-02 08:44:56 +02:00
feat: use replyTargets config for platform-to-syndicator mapping
- Frontend now reads replyTargets from isOwner API to resolve which syndicator handles replies for each platform - Build-time reply buttons get platform from URL heuristics as fallback - enrichBuildTimeBadges upgrades to NodeInfo-resolved platform at runtime
This commit is contained in:
@@ -153,9 +153,19 @@
|
||||
<div class="text-surface-700 dark:text-surface-300 prose dark:prose-invert prose-sm max-w-none">
|
||||
{{ reply.content.html | safe if reply.content.html else reply.content.text }}
|
||||
</div>
|
||||
{% set replySource = reply['wm-source'] | default('', true) %}
|
||||
{% set replyAuthorUrl = reply.author.url | default('', true) %}
|
||||
{% set buildPlatform = 'webmention' %}
|
||||
{% if 'bsky.app' in replyAuthorUrl or ('brid.gy/' in replySource and '/bluesky/' in replySource) %}
|
||||
{% set buildPlatform = 'bluesky' %}
|
||||
{% elif 'brid.gy/' in replySource and '/mastodon/' in replySource %}
|
||||
{% set buildPlatform = 'mastodon' %}
|
||||
{% elif 'fed.brid.gy' in replySource %}
|
||||
{% set buildPlatform = 'activitypub' %}
|
||||
{% endif %}
|
||||
<button class="wm-reply-btn hidden text-xs text-primary-600 dark:text-primary-400 hover:underline mt-2"
|
||||
data-reply-url="{{ reply.url }}"
|
||||
data-platform="">
|
||||
data-platform="{{ buildPlatform }}">
|
||||
Reply
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -12,6 +12,7 @@ document.addEventListener("alpine:init", () => {
|
||||
isOwner: false,
|
||||
profile: null,
|
||||
syndicationTargets: {},
|
||||
replyTargets: {},
|
||||
});
|
||||
|
||||
Alpine.data("commentsSection", (targetUrl) => ({
|
||||
@@ -74,11 +75,13 @@ document.addEventListener("alpine:init", () => {
|
||||
photo: data.photo,
|
||||
};
|
||||
this.syndicationTargets = data.syndicationTargets || {};
|
||||
this.replyTargets = data.replyTargets || {};
|
||||
|
||||
// Also update global store for webmentions component
|
||||
Alpine.store("owner").isOwner = true;
|
||||
Alpine.store("owner").profile = this.ownerProfile;
|
||||
Alpine.store("owner").syndicationTargets = this.syndicationTargets;
|
||||
Alpine.store("owner").replyTargets = this.replyTargets;
|
||||
|
||||
// Note: owner:detected event is dispatched from init() after
|
||||
// this completes, so the Alpine store is populated before the event fires
|
||||
|
||||
@@ -803,12 +803,11 @@
|
||||
btn.addEventListener('click', function() {
|
||||
var replyUrl = btn.dataset.replyUrl;
|
||||
var platform = btn.dataset.platform || 'webmention';
|
||||
// Map detected platform to syndicator by service.name
|
||||
// Map platform to syndicator via replyTargets config
|
||||
var targets = ownerStore.syndicationTargets || {};
|
||||
var syndicateTo = null;
|
||||
if (platform === 'bluesky') syndicateTo = targets['Bluesky'] || null;
|
||||
if (platform === 'mastodon') syndicateTo = targets['Mastodon'] || null;
|
||||
if (platform === 'activitypub') syndicateTo = targets['ActivityPub (Fediverse)'] || null;
|
||||
var replyTargets = ownerStore.replyTargets || {};
|
||||
var serviceName = replyTargets[platform] || null;
|
||||
var syndicateTo = serviceName ? (targets[serviceName] || null) : null;
|
||||
|
||||
// Close any existing reply form
|
||||
closeActiveReplyForm();
|
||||
|
||||
Reference in New Issue
Block a user