astro-buffalo 0.1.2 → 0.2.0
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/README.md +6 -0
- package/dist/index.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Share newly published Astro articles to Buffer using its experimental `createContentItem` API.
|
|
4
4
|
One request per article, with a variant for each channel. No SDK, database, or browser JavaScript.
|
|
5
5
|
|
|
6
|
+
An independent integration; not affiliated with or endorsed by Buffer.
|
|
7
|
+
|
|
6
8
|
## Setup
|
|
7
9
|
|
|
8
10
|
Requires Astro 7.x and Node 24 or newer.
|
|
@@ -62,6 +64,7 @@ The endpoint must return a JSON array with these fields on each article:
|
|
|
62
64
|
| `title` | Yes | Non-empty article title, also used as the default announcement. |
|
|
63
65
|
| `url` | Yes | Absolute HTTP(S) canonical production URL, without whitespace, credentials, or a fragment. Must match the deployed URL without a redirect. |
|
|
64
66
|
| `text` | No | Non-empty custom announcement text; the article URL is always appended. |
|
|
67
|
+
| `mode` | No | `shareNow` or `addToQueue`; overrides the integration's default for this article. |
|
|
65
68
|
|
|
66
69
|
An empty array is valid; invalid entries stop the build before any Buffer requests.
|
|
67
70
|
Adapt the collection name and routes to your site. Include only public articles, filtering drafts
|
|
@@ -103,6 +106,9 @@ mode: "addToQueue",
|
|
|
103
106
|
`mode` supports `shareNow` (default) and `addToQueue`; both use automatic delivery.
|
|
104
107
|
Disconnected or locked channels are reported and skipped.
|
|
105
108
|
|
|
109
|
+
For different choices per article, return `mode` in each manifest entry. Articles without a
|
|
110
|
+
mode use the integration setting.
|
|
111
|
+
|
|
106
112
|
Announcements use `title + "\n\n" + url`. Add `text: post.data.description` to an article's manifest
|
|
107
113
|
entry for custom copy; the content item's title stays unchanged. Custom text is trimmed and must
|
|
108
114
|
be non-empty. The URL is always appended for duplicate detection.
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ const articlesSchema = z.array(z.object({
|
|
|
23
23
|
.string({ message: "announcement text must be a non-empty string." })
|
|
24
24
|
.refine((text) => text.trim(), "announcement text must be a non-empty string.")
|
|
25
25
|
.optional(),
|
|
26
|
+
mode: z.enum(["shareNow", "addToQueue"]).optional(),
|
|
26
27
|
}, { message: "must be an object." }), { message: "Buffer manifest must be an array of articles." });
|
|
27
28
|
function isDraft(source) {
|
|
28
29
|
const lines = (source.startsWith("\uFEFF") ? source.slice(1) : source).split("\n");
|
|
@@ -163,6 +164,7 @@ export default function buffer({ posts: entrypoint, contentDirectory, channelIds
|
|
|
163
164
|
.map((article) => ({
|
|
164
165
|
...article,
|
|
165
166
|
text: `${article.text?.trim() ?? article.title}\n\n${article.url}`,
|
|
167
|
+
mode: article.mode ?? mode,
|
|
166
168
|
}));
|
|
167
169
|
if (!posts.length) {
|
|
168
170
|
logger.info("No new blog posts to share.");
|
|
@@ -237,7 +239,7 @@ export default function buffer({ posts: entrypoint, contentDirectory, channelIds
|
|
|
237
239
|
title: article.title,
|
|
238
240
|
text: article.text,
|
|
239
241
|
channels: pending.map(({ id, name }) => ({ id, name })),
|
|
240
|
-
mode,
|
|
242
|
+
mode: article.mode,
|
|
241
243
|
})}`);
|
|
242
244
|
continue;
|
|
243
245
|
}
|
|
@@ -258,7 +260,7 @@ export default function buffer({ posts: entrypoint, contentDirectory, channelIds
|
|
|
258
260
|
channelId: id,
|
|
259
261
|
text: article.text,
|
|
260
262
|
schedulingType: "automatic",
|
|
261
|
-
mode,
|
|
263
|
+
mode: article.mode,
|
|
262
264
|
})),
|
|
263
265
|
},
|
|
264
266
|
});
|