feat: add getSyndicationUrl hook to syndicator interface - #882
feat: add getSyndicationUrl hook to syndicator interface#882aciccarello wants to merge 4 commits into
getSyndicationUrl hook to syndicator interface#882Conversation
getSyndicationUrl hook to syndicator interface
67b3847 to
fa1d368
Compare
|
The hook solves the ordering problem in the right place — running it in One thing worth surfacing, because this PR works around it without naming it. const targetOrigin = new URL(target.info.uid).origin;
const syndicateToOrigin = new URL(syndicateTo).origin;
return targetOrigin === syndicateToOrigin;IndieNews registers one target per language on a single origin, so those collapse into one. With This PR matches Smaller point: |
Indiekit selects a syndication target by comparing URL origins, and every IndieNews language shares one. A request for `https://news.indieweb.org/fr` is therefore handed to whichever IndieNews target registered first, which is usually the English one. That is not only a wrong label. The webmention names the channel it is submitted to, and IndieNews requires the post to link to that same channel, so a post carrying a `u-syndication` link to `/fr` submitted with a target of `/en` is rejected. Read the language back out of `mp-syndicate-to`, which Indiekit passes to `syndicate()`, and fall back to the configured one when no IndieNews target was requested. This covers one language per post. Requesting two in a single post still loses the second: `hasSyndicationUrl` also compares origins, so once one IndieNews permalink is recorded the rest are treated as already syndicated. That needs the exact matching proposed upstream in getindiekit/indiekit#882. Adds the first tests for this package, run with `node --test`.
Closes #860
Summary
Adds an optional
getSyndicationUrl(publication)hook to the syndicator plugin interface, enabling syndication URLs to be written into post files at creation time — without requiring a database or async syndication step.This is needed for webmention-based syndication targets where the syndication URL is known at post creation time, but
mp-syndicate-tois stripped before the file is written (correct per the Micropub spec — it is a server command, not a content property).Changes
endpoint-syndicatesyndicate()is now optional on syndicator targets. Targets without it are skipped rather than throwing. This allows syndicators that only implementgetSyndicationUrl()to register without providing an empty no-op.endpoint-micropubpost-content.jscreate(), after resolving syndication targets and beforegetPostTemplateProperties()stripsmp-*keys, callsgetSyndicationUrl(publication)on any target whoseinfo.uidis inmp-syndicate-to.syndicationvalues (exact string match), and appended toproperties.syndication.getSyndicationUrl()are caught and logged viadebug()— the create request is never failed.Interface
A syndicator implementing this hook can return the syndication URL synchronously at post creation time. The endpoint handles appending it to
syndicationbefore the file is written.This is scoped to
create()only. Update behaviour is a separate concern.