@tryghost/mg-substack 0.3.24 → 0.4.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/process.js +21 -2
- package/package.json +4 -4
package/lib/process.js
CHANGED
|
@@ -94,6 +94,22 @@ const processContent = (post, siteUrl, options) => {
|
|
|
94
94
|
scriptingEnabled: false
|
|
95
95
|
}, false); // This `false` is `isDocument`. If `true`, <html>, <head>, and <body> elements are introduced
|
|
96
96
|
|
|
97
|
+
// Convert bucketeer image paths
|
|
98
|
+
$html('a[href^="https://bucketeer-"], img[src^="https://bucketeer-"]').each((i, el) => {
|
|
99
|
+
const href = $(el).attr('href') ?? false;
|
|
100
|
+
const src = $(el).attr('src') ?? false;
|
|
101
|
+
|
|
102
|
+
const prependString = 'https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/';
|
|
103
|
+
|
|
104
|
+
if (href) {
|
|
105
|
+
$(el).attr('href', `${prependString}${encodeURI(href)}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (src) {
|
|
109
|
+
$(el).attr('src', `${prependString}${encodeURI(src)}`);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
97
113
|
// Empty text elements are commonplace and are not needed
|
|
98
114
|
$html('p').each((i, el) => {
|
|
99
115
|
let content = $(el).html().trim();
|
|
@@ -206,11 +222,14 @@ const processContent = (post, siteUrl, options) => {
|
|
|
206
222
|
payload: {
|
|
207
223
|
src: imageSrc,
|
|
208
224
|
alt: imgAlt,
|
|
209
|
-
caption: imgCaption
|
|
210
|
-
href: linkHref
|
|
225
|
+
caption: imgCaption
|
|
211
226
|
}
|
|
212
227
|
};
|
|
213
228
|
|
|
229
|
+
if (imageSrc !== linkHref) {
|
|
230
|
+
cardOpts.payload.href = linkHref;
|
|
231
|
+
}
|
|
232
|
+
|
|
214
233
|
$(div).replaceWith(serializer.serialize(imageCard.render(cardOpts)));
|
|
215
234
|
});
|
|
216
235
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-substack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-substack",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"eslint": "8.
|
|
23
|
+
"eslint": "8.56.0",
|
|
24
24
|
"jest": "29.7.0",
|
|
25
25
|
"jest-extended": "4.0.2"
|
|
26
26
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@tryghost/debug": "0.1.27",
|
|
29
29
|
"@tryghost/errors": "1.3.0",
|
|
30
30
|
"@tryghost/kg-default-cards": "9.1.9",
|
|
31
|
-
"@tryghost/mg-fs-utils": "^0.12.
|
|
31
|
+
"@tryghost/mg-fs-utils": "^0.12.22",
|
|
32
32
|
"@tryghost/string": "0.2.11",
|
|
33
33
|
"cheerio": "1.0.0-rc.12",
|
|
34
34
|
"date-fns": "2.30.0",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"simple-dom": "1.4.0",
|
|
38
38
|
"srcset": "5.0.0"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "544b1dbe8477cd2621f6fee9d3b7f58a68fb7198"
|
|
41
41
|
}
|