@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.
@@ -62,7 +62,6 @@ export const postsController = async (request, response, next) => {
62
62
  item.icon = item["post-type"];
63
63
  item.locale = application.locale;
64
64
  item.photo = getPhotoUrl(publication, item);
65
-
66
65
  item.description = {
67
66
  text:
68
67
  item.summary ||
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
- label: target.info.service.name,
375
- ...(target?.info?.error
376
- ? {
377
- disabled: true,
378
- hint: target?.info?.error || false,
379
- }
380
- : {
381
- hint: target?.info.uid,
382
- value: target?.info.uid,
383
- ...(checkTargets && { checked: target.options.checked }),
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.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",