@tryghost/mg-substack 0.8.8 → 0.8.10
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/README.md +8 -4
- package/lib/process.js +27 -4
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -55,10 +55,11 @@ It's possible to pass more options, in order to achieve a better migration file
|
|
|
55
55
|
- **`-s` `--scrape`**
|
|
56
56
|
- Configure scraping tasks
|
|
57
57
|
- string - default: `all`
|
|
58
|
-
- Choices: `all`, `
|
|
59
|
-
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
- Choices: `all`, `web`, `assets`, `none`
|
|
59
|
+
- `all`: Scrape web metadata and download assets
|
|
60
|
+
- `web`: Only scrape metadata from web pages
|
|
61
|
+
- `assets`: Only download assets (images, media, files)
|
|
62
|
+
- `none`: Skip all scraping tasks
|
|
62
63
|
- **`-e` `--email`**
|
|
63
64
|
- Provide an email domain for users e.g. `person@example.com` (Is ignored if `--useMetaAuthor` is provided)
|
|
64
65
|
- bool/string - default: `false`
|
|
@@ -92,6 +93,9 @@ It's possible to pass more options, in order to achieve a better migration file
|
|
|
92
93
|
- **`--subscribeLink`**
|
|
93
94
|
- Provide a path that existing `/subscribe` anchors will link to e.g. `/join-us` or `#/portal/signup` (`#` characters need to be escaped with a `\`)
|
|
94
95
|
- string - default: `#/portal/signup`
|
|
96
|
+
- **`--noSubscribeButtons`**
|
|
97
|
+
- Remove subscribe buttons and links from content (no replacement link)
|
|
98
|
+
- bool - default: `false`
|
|
95
99
|
- **`--comments`**
|
|
96
100
|
- Keep comment buttons
|
|
97
101
|
- bool - default: `true`
|
package/lib/process.js
CHANGED
|
@@ -561,6 +561,10 @@ const processContent = (post, siteUrl, options) => {
|
|
|
561
561
|
}
|
|
562
562
|
|
|
563
563
|
if (buttonHref === '/subscribe/') {
|
|
564
|
+
if (options.noSubscribeButtons) {
|
|
565
|
+
$html(button).remove();
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
564
568
|
buttonHref = options.subscribeLink || '#/portal/signup';
|
|
565
569
|
}
|
|
566
570
|
|
|
@@ -621,8 +625,23 @@ const processContent = (post, siteUrl, options) => {
|
|
|
621
625
|
}
|
|
622
626
|
});
|
|
623
627
|
|
|
624
|
-
//
|
|
625
|
-
if (options.
|
|
628
|
+
// Remove or replace subscribe links on the same domain
|
|
629
|
+
if (options.noSubscribeButtons) {
|
|
630
|
+
$html('a').each((i, anchor) => {
|
|
631
|
+
let href = $html(anchor).attr('href');
|
|
632
|
+
let linkRegex = new RegExp(`^(${siteUrl})?(/subscribe)(.*)`, 'gi');
|
|
633
|
+
|
|
634
|
+
if (!href) {
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
let matches = href.replace(linkRegex, '$2');
|
|
639
|
+
|
|
640
|
+
if (matches === '/subscribe') {
|
|
641
|
+
$html(anchor).remove();
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
} else if (options.subscribeLink) {
|
|
626
645
|
$html('a').each((i, anchor) => {
|
|
627
646
|
let href = $html(anchor).attr('href');
|
|
628
647
|
let linkRegex = new RegExp(`^(${siteUrl})?(/subscribe)(.*)`, 'gi');
|
|
@@ -639,8 +658,12 @@ const processContent = (post, siteUrl, options) => {
|
|
|
639
658
|
});
|
|
640
659
|
}
|
|
641
660
|
|
|
642
|
-
//
|
|
643
|
-
if (options.
|
|
661
|
+
// Remove or replace signup forms with a Portal signup button
|
|
662
|
+
if (options.noSubscribeButtons) {
|
|
663
|
+
$html('.subscription-widget-wrap, .subscription-widget-wrap-editor').each((i, div) => {
|
|
664
|
+
$html(div).remove();
|
|
665
|
+
});
|
|
666
|
+
} else if (options.subscribeLink) {
|
|
644
667
|
$html('.subscription-widget-wrap, .subscription-widget-wrap-editor').each((i, div) => {
|
|
645
668
|
const hasForm = $html(div).find('form');
|
|
646
669
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-substack",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.10",
|
|
4
4
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-substack",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,21 +21,21 @@
|
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"eslint": "8.57.0",
|
|
24
|
-
"jest": "30.0
|
|
25
|
-
"jest-extended": "
|
|
24
|
+
"jest": "30.2.0",
|
|
25
|
+
"jest-extended": "7.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tryghost/debug": "0.1.
|
|
28
|
+
"@tryghost/debug": "0.1.36",
|
|
29
29
|
"@tryghost/errors": "1.3.8",
|
|
30
|
-
"@tryghost/kg-default-cards": "10.2.
|
|
31
|
-
"@tryghost/mg-fs-utils": "0.16.
|
|
30
|
+
"@tryghost/kg-default-cards": "10.2.6",
|
|
31
|
+
"@tryghost/mg-fs-utils": "0.16.5",
|
|
32
32
|
"@tryghost/string": "0.2.21",
|
|
33
|
-
"cheerio": "1.
|
|
33
|
+
"cheerio": "1.2.0",
|
|
34
34
|
"he": "1.2.0",
|
|
35
35
|
"html-entities": "2.6.0",
|
|
36
|
-
"lodash": "4.17.
|
|
36
|
+
"lodash": "4.17.23",
|
|
37
37
|
"simple-dom": "1.4.0",
|
|
38
38
|
"srcset": "5.0.3"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "5526338b0a5aee977b735a03f490d21f60c10ebd"
|
|
41
41
|
}
|