@tryghost/mg-substack 0.3.23 → 0.4.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.
Files changed (2) hide show
  1. package/lib/process.js +21 -2
  2. package/package.json +7 -7
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}${href.replace($(el).attr('href'), encodeURI(href))}`);
106
+ }
107
+
108
+ if (src) {
109
+ $(el).attr('src', `${prependString}${src.replace($(el).attr('src'), 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.23",
3
+ "version": "0.4.0",
4
4
  "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-substack",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -20,16 +20,16 @@
20
20
  "access": "public"
21
21
  },
22
22
  "devDependencies": {
23
- "eslint": "8.54.0",
23
+ "eslint": "8.56.0",
24
24
  "jest": "29.7.0",
25
25
  "jest-extended": "4.0.2"
26
26
  },
27
27
  "dependencies": {
28
- "@tryghost/debug": "0.1.26",
29
- "@tryghost/errors": "1.2.26",
28
+ "@tryghost/debug": "0.1.27",
29
+ "@tryghost/errors": "1.3.0",
30
30
  "@tryghost/kg-default-cards": "9.1.9",
31
- "@tryghost/mg-fs-utils": "^0.12.20",
32
- "@tryghost/string": "0.2.10",
31
+ "@tryghost/mg-fs-utils": "^0.12.22",
32
+ "@tryghost/string": "0.2.11",
33
33
  "cheerio": "1.0.0-rc.12",
34
34
  "date-fns": "2.30.0",
35
35
  "html-entities": "2.4.0",
@@ -37,5 +37,5 @@
37
37
  "simple-dom": "1.4.0",
38
38
  "srcset": "5.0.0"
39
39
  },
40
- "gitHead": "87eac9f1a90b9e8935ce70d9459db6f8ffec6133"
40
+ "gitHead": "eff0d7d7ba1a0ce1d89dd15a0671b23ea4ef9307"
41
41
  }