@rmdes/indiekit-endpoint-posts 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/controllers/posts.js +0 -1
- package/lib/utils.js +31 -13
- package/package.json +1 -1
package/lib/controllers/posts.js
CHANGED
package/lib/utils.js
CHANGED
|
@@ -370,19 +370,37 @@ export const getPostUrl = (id) => {
|
|
|
370
370
|
* @returns {object} Items for checkboxes component
|
|
371
371
|
*/
|
|
372
372
|
export const getSyndicateToItems = (publication, checkTargets = false) => {
|
|
373
|
-
return publication.syndicationTargets.map((target) =>
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
373
|
+
return publication.syndicationTargets.map((target) => {
|
|
374
|
+
// A misconfigured syndicator must never crash a core feature (the post
|
|
375
|
+
// editor). Reading `target.info` can throw — the getter builds URLs from
|
|
376
|
+
// plugin config (e.g. `new URL(MASTODON_INSTANCE)` throws on an empty
|
|
377
|
+
// value). Contain it and surface the target as a disabled item with a
|
|
378
|
+
// hint, exactly as we do for a target that reports `info.error`.
|
|
379
|
+
let info;
|
|
380
|
+
try {
|
|
381
|
+
info = target.info;
|
|
382
|
+
} catch (error) {
|
|
383
|
+
return {
|
|
384
|
+
label: target?.options?.name || target?.name || "Syndication target",
|
|
385
|
+
disabled: true,
|
|
386
|
+
hint: error.message || "Syndicator is not configured correctly",
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return {
|
|
391
|
+
label: info?.service?.name || target?.name || "Syndication target",
|
|
392
|
+
...(info?.error
|
|
393
|
+
? {
|
|
394
|
+
disabled: true,
|
|
395
|
+
hint: info.error || false,
|
|
396
|
+
}
|
|
397
|
+
: {
|
|
398
|
+
hint: info?.uid,
|
|
399
|
+
value: info?.uid,
|
|
400
|
+
...(checkTargets && { checked: target.options?.checked }),
|
|
401
|
+
}),
|
|
402
|
+
};
|
|
403
|
+
});
|
|
386
404
|
};
|
|
387
405
|
|
|
388
406
|
/** Directory name → post-type mapping */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmdes/indiekit-endpoint-posts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Post management endpoint for Indiekit with syndicate form fix. View posts published by your Micropub endpoint and publish new posts to it.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"indiekit",
|