@tryghost/mg-substack 0.4.3 → 0.5.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/lib/process.js +31 -7
- package/package.json +3 -3
package/lib/process.js
CHANGED
|
@@ -231,16 +231,40 @@ const processContent = (post, siteUrl, options) => {
|
|
|
231
231
|
}
|
|
232
232
|
src = url.format(parsed, {search: false});
|
|
233
233
|
|
|
234
|
-
let tweetText = $(el)
|
|
235
|
-
let tweetAuthorName = $(el)
|
|
236
|
-
let tweetAuthorHandle = $(el)
|
|
237
|
-
let tweetDateTime = $(el)
|
|
238
|
-
let tweetURL = $(el)
|
|
234
|
+
let tweetText = $(el)?.find('.tweet-text')?.html()?.replace(/(?:\r\n|\r|\n)/g, '<br>') ?? false;
|
|
235
|
+
let tweetAuthorName = $(el)?.find('.tweet-author-name')?.html()?.trim() ?? false;
|
|
236
|
+
let tweetAuthorHandle = $(el)?.find('.tweet-author-handle')?.html()?.trim() ?? false;
|
|
237
|
+
let tweetDateTime = $(el)?.find('.tweet-date')?.text()?.trim() ?? false;
|
|
238
|
+
let tweetURL = $(el)?.find('.tweet-link-top')?.attr('href') ?? false;
|
|
239
239
|
|
|
240
|
-
let theHtml =
|
|
240
|
+
let theHtml = [];
|
|
241
|
+
|
|
242
|
+
if (tweetText) {
|
|
243
|
+
theHtml.push(`<p lang="en" dir="ltr">${tweetText}</p>`);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
theHtml.push(`—`);
|
|
247
|
+
|
|
248
|
+
if (tweetAuthorName) {
|
|
249
|
+
theHtml.push(`${tweetAuthorName}`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (tweetAuthorHandle) {
|
|
253
|
+
theHtml.push(`(${tweetAuthorHandle})`);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (tweetURL) {
|
|
257
|
+
theHtml.push(`<a href="${tweetURL}">`);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (tweetDateTime) {
|
|
261
|
+
theHtml.push(`${tweetDateTime}`);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
theHtml.push(`</a>`);
|
|
241
265
|
|
|
242
266
|
let $figure = $('<figure class="kg-card kg-embed-card"></figure>');
|
|
243
|
-
let $blockquote = $(`<blockquote class="twitter-tweet">${theHtml}</blockquote>`);
|
|
267
|
+
let $blockquote = $(`<blockquote class="twitter-tweet">${theHtml.join(' ')}</blockquote>`);
|
|
244
268
|
let $anchor = $(`<a href="${src}"></a>`);
|
|
245
269
|
let $script = $('<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>');
|
|
246
270
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-substack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-substack",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@tryghost/debug": "0.1.27",
|
|
29
29
|
"@tryghost/errors": "1.3.0",
|
|
30
|
-
"@tryghost/kg-default-cards": "10.0.
|
|
30
|
+
"@tryghost/kg-default-cards": "10.0.2",
|
|
31
31
|
"@tryghost/mg-fs-utils": "^0.13.0",
|
|
32
32
|
"@tryghost/string": "0.2.11",
|
|
33
33
|
"cheerio": "1.0.0-rc.12",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"simple-dom": "1.4.0",
|
|
39
39
|
"srcset": "5.0.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "d0c6f970f484101ab9b4dcf8ba95fa1398da4b79"
|
|
42
42
|
}
|