@tryghost/mg-substack 0.3.15 → 0.3.16
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 +12 -4
- package/package.json +5 -5
package/lib/process.js
CHANGED
|
@@ -34,6 +34,10 @@ const readFiles = async (files, postsDir) => {
|
|
|
34
34
|
return postContent;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
const largeImageUrl = (src) => {
|
|
38
|
+
return src.replace(/w_[0-9]{2,5},h_[0-9]{2,5}/, 'w_2000,h_2000');
|
|
39
|
+
};
|
|
40
|
+
|
|
37
41
|
const getUnsizedImageName = (str) => {
|
|
38
42
|
const noSizeRegex = /(.*)(_[0-9]{1,4}x[0-9]{1,4}.[a-z]{2,4})/gmi;
|
|
39
43
|
let srcParts = str.split(/\/|%2F/);
|
|
@@ -72,8 +76,8 @@ const largestSrc = ($imageElem) => {
|
|
|
72
76
|
};
|
|
73
77
|
|
|
74
78
|
const processContent = (post, siteUrl, options) => {
|
|
75
|
-
const {substackPodcastURL
|
|
76
|
-
const
|
|
79
|
+
const {substackPodcastURL} = post;
|
|
80
|
+
const {useMetaImage} = options;
|
|
77
81
|
|
|
78
82
|
let html = post.data?.html;
|
|
79
83
|
|
|
@@ -99,7 +103,11 @@ const processContent = (post, siteUrl, options) => {
|
|
|
99
103
|
});
|
|
100
104
|
|
|
101
105
|
// We use the `'og:image` as the feature image. If the first item in the content is an image and is the same as the `og:image`, remove it
|
|
102
|
-
if (
|
|
106
|
+
if (post.data?.og_image) {
|
|
107
|
+
if (useMetaImage) {
|
|
108
|
+
post.data.feature_image = largeImageUrl(post.data.og_image);
|
|
109
|
+
}
|
|
110
|
+
|
|
103
111
|
let firstElement = $html('body *').first();
|
|
104
112
|
|
|
105
113
|
if (firstElement.tagName === 'img' || ($(firstElement).get(0) && $(firstElement).get(0).name === 'img') || $(firstElement).find('img').length) {
|
|
@@ -109,7 +117,7 @@ const processContent = (post, siteUrl, options) => {
|
|
|
109
117
|
if (firstImgSrc.length > 0) {
|
|
110
118
|
let unsizedFirstSrc = getUnsizedImageName(firstImgSrc);
|
|
111
119
|
|
|
112
|
-
let ogImgSrc =
|
|
120
|
+
let ogImgSrc = post.data.og_image;
|
|
113
121
|
let unsizedOgSrc = getUnsizedImageName(ogImgSrc);
|
|
114
122
|
|
|
115
123
|
if (unsizedFirstSrc === unsizedOgSrc) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-substack",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.16",
|
|
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.44.0",
|
|
24
24
|
"jest": "29.5.0",
|
|
25
25
|
"jest-extended": "3.2.4"
|
|
26
26
|
},
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"@tryghost/debug": "0.1.25",
|
|
29
29
|
"@tryghost/errors": "1.2.25",
|
|
30
30
|
"@tryghost/kg-default-cards": "9.1.0",
|
|
31
|
-
"@tryghost/mg-fs-utils": "^0.12.
|
|
31
|
+
"@tryghost/mg-fs-utils": "^0.12.14",
|
|
32
32
|
"@tryghost/string": "0.2.7",
|
|
33
33
|
"date-fns": "2.30.0",
|
|
34
|
-
"html-entities": "2.
|
|
34
|
+
"html-entities": "2.4.0",
|
|
35
35
|
"lodash": "4.17.21",
|
|
36
36
|
"simple-dom": "1.4.0",
|
|
37
37
|
"srcset": "5.0.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "858b985d1e54eaf41b3a53dbccdc074b57246f9c"
|
|
40
40
|
}
|