backend-manager 5.9.18 → 5.9.19
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/package.json
CHANGED
|
@@ -154,14 +154,17 @@ async function harvest(assistant, entry, admin, provider, Manager) {
|
|
|
154
154
|
|
|
155
155
|
assistant.log('harvest(): Article', article);
|
|
156
156
|
|
|
157
|
-
const
|
|
157
|
+
const publishArgs = {
|
|
158
158
|
brand: entry.brand,
|
|
159
159
|
article,
|
|
160
160
|
id: postId++,
|
|
161
161
|
author: entry.author,
|
|
162
162
|
postPath: entry.postPath,
|
|
163
163
|
source: resolved.trackingData?.url || null,
|
|
164
|
-
}
|
|
164
|
+
};
|
|
165
|
+
assistant.log('harvest(): publishArgs', publishArgs);
|
|
166
|
+
|
|
167
|
+
const uploadedPost = await provider.publishArticle(assistant, publishArgs).catch((e) => e);
|
|
165
168
|
if (uploadedPost instanceof Error) {
|
|
166
169
|
assistant.error('harvest(): Error uploading post to blog', uploadedPost);
|
|
167
170
|
break;
|
|
@@ -131,8 +131,7 @@ function blocksToPost(json) {
|
|
|
131
131
|
* @returns {Promise<object>} { post, url, slug, path } — `url` is the public blog URL
|
|
132
132
|
*/
|
|
133
133
|
async function publishArticle(assistant, { brand, article, id, author, postPath, source }) {
|
|
134
|
-
const
|
|
135
|
-
const apiUrl = `https://api.${baseUrl}`;
|
|
134
|
+
const apiUrl = assistant.Manager.getApiUrl();
|
|
136
135
|
|
|
137
136
|
// Transform Ghostii's generic JSON into BEM's post shape (title + header image
|
|
138
137
|
// as separate fields, body = content only). Fall back to the legacy flat fields
|
|
@@ -142,27 +141,31 @@ async function publishArticle(assistant, { brand, article, id, author, postPath,
|
|
|
142
141
|
const headerImageUrl = post.headerImageUrl || article.headerImageUrl;
|
|
143
142
|
const body = article.json ? post.body : article.body;
|
|
144
143
|
|
|
144
|
+
const postBody = {
|
|
145
|
+
backendManagerKey: process.env.BACKEND_MANAGER_KEY,
|
|
146
|
+
title: title,
|
|
147
|
+
url: title,
|
|
148
|
+
description: article.description,
|
|
149
|
+
headerImageURL: headerImageUrl,
|
|
150
|
+
body: body,
|
|
151
|
+
id: id,
|
|
152
|
+
author: author,
|
|
153
|
+
categories: article.categories,
|
|
154
|
+
tags: article.keywords,
|
|
155
|
+
postPath: postPath || 'ghostii',
|
|
156
|
+
source: source || null,
|
|
157
|
+
githubUser: brand.github.user,
|
|
158
|
+
githubRepo: brand.github.repo,
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
console.log(`[ghostii] publishArticle() source=${postBody.source}`);
|
|
162
|
+
|
|
145
163
|
const result = await fetch(`${apiUrl}/backend-manager/admin/post`, {
|
|
146
164
|
method: 'POST',
|
|
147
165
|
timeout: 90000,
|
|
148
166
|
tries: 1,
|
|
149
167
|
response: 'json',
|
|
150
|
-
body:
|
|
151
|
-
backendManagerKey: process.env.BACKEND_MANAGER_KEY,
|
|
152
|
-
title: title,
|
|
153
|
-
url: title, // Slugified on the admin/post endpoint
|
|
154
|
-
description: article.description,
|
|
155
|
-
headerImageURL: headerImageUrl,
|
|
156
|
-
body: body,
|
|
157
|
-
id: id,
|
|
158
|
-
author: author,
|
|
159
|
-
categories: article.categories,
|
|
160
|
-
tags: article.keywords,
|
|
161
|
-
postPath: postPath || 'ghostii',
|
|
162
|
-
source: source || null,
|
|
163
|
-
githubUser: brand.github.user,
|
|
164
|
-
githubRepo: brand.github.repo,
|
|
165
|
-
},
|
|
168
|
+
body: postBody,
|
|
166
169
|
});
|
|
167
170
|
|
|
168
171
|
// admin/post returns the resolved `settings` (incl. the slugified `url` and repo `path`).
|
|
@@ -15,6 +15,7 @@ module.exports = () => ({
|
|
|
15
15
|
date: { types: ['string'], default: undefined },
|
|
16
16
|
id: { types: ['number'], default: undefined },
|
|
17
17
|
postPath: { types: ['string'], default: 'guest' },
|
|
18
|
+
source: { types: ['string'], default: null },
|
|
18
19
|
githubUser: { types: ['string'], default: undefined },
|
|
19
20
|
githubRepo: { types: ['string'], default: undefined },
|
|
20
21
|
});
|