@tryghost/mg-jekyll-export 0.3.39 → 0.3.41
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/LICENSE +1 -1
- package/README.md +6 -5
- package/lib/process-html.js +13 -10
- package/package.json +8 -8
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -52,10 +52,11 @@ It's possible to pass more options, in order to achieve a better migration file
|
|
|
52
52
|
- **`-s` `--scrape`**
|
|
53
53
|
- Configure scraping tasks
|
|
54
54
|
- string - default: `all`
|
|
55
|
-
- Choices: `all`, `
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
- Choices: `all`, `web`, `assets`, `none`
|
|
56
|
+
- `all`: Scrape web metadata and download assets
|
|
57
|
+
- `web`: Only scrape metadata from web pages
|
|
58
|
+
- `assets`: Only download assets (images, media, files)
|
|
59
|
+
- `none`: Skip all scraping tasks
|
|
59
60
|
- **`-u` `--url`**
|
|
60
61
|
- string - default: `false`
|
|
61
62
|
- Provide a URL (without trailing slash) to the hosted source site
|
|
@@ -112,4 +113,4 @@ yarn dev jekyll --pathToZip /path/to/site.zip
|
|
|
112
113
|
|
|
113
114
|
# Copyright & License
|
|
114
115
|
|
|
115
|
-
Copyright (c) 2013-
|
|
116
|
+
Copyright (c) 2013-2026 Ghost Foundation - Released under the [MIT license](LICENSE).
|
package/lib/process-html.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as cheerio from 'cheerio';
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
Process the HTML of a single Jekyll Post.
|
|
@@ -7,9 +7,12 @@ Receives raw HTML, returns processed HTML
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
export default (rawHtml, options = {}) => {
|
|
10
|
-
const $html =
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const $html = cheerio.load(rawHtml, {
|
|
11
|
+
xml: {
|
|
12
|
+
xmlMode: false,
|
|
13
|
+
decodeEntities: false,
|
|
14
|
+
scriptingEnabled: false
|
|
15
|
+
}
|
|
13
16
|
}, false); // This `false` is `isDocument`. If `true`, <html>, <head>, and <body> elements are introduced
|
|
14
17
|
|
|
15
18
|
// Convert relative links and image paths to absolute
|
|
@@ -21,32 +24,32 @@ export default (rawHtml, options = {}) => {
|
|
|
21
24
|
const urlOrigin = urlData.origin;
|
|
22
25
|
|
|
23
26
|
$html('a').each((i, anchor) => {
|
|
24
|
-
const thisURL = $(anchor).attr('href');
|
|
27
|
+
const thisURL = $html(anchor).attr('href');
|
|
25
28
|
|
|
26
29
|
// If it starts with a slash, append the base URL
|
|
27
30
|
if (thisURL && thisURL.indexOf('/') === 0) {
|
|
28
31
|
const updatedURL = `${urlOrigin.replace(/^\/|\/$/g, '')}/${thisURL.replace(/^\/|\/$/g, '')}`;
|
|
29
|
-
$(anchor).attr('href', updatedURL);
|
|
32
|
+
$html(anchor).attr('href', updatedURL);
|
|
30
33
|
}
|
|
31
34
|
});
|
|
32
35
|
|
|
33
36
|
$html('img').each((i, img) => {
|
|
34
|
-
const thisSrc = $(img).attr('src');
|
|
37
|
+
const thisSrc = $html(img).attr('src');
|
|
35
38
|
|
|
36
39
|
// If it starts with a slash, append the base URL
|
|
37
40
|
if (thisSrc && thisSrc.indexOf('/') === 0) {
|
|
38
41
|
const updatedURL = `${urlOrigin.replace(/^\/|\/$/g, '')}/${thisSrc.replace(/^\/|\/$/g, '')}`;
|
|
39
|
-
$(img).attr('src', updatedURL);
|
|
42
|
+
$html(img).attr('src', updatedURL);
|
|
40
43
|
}
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
// Unwrap <p> tags that are in <li> tags
|
|
45
48
|
$html('li').each((i, li) => {
|
|
46
|
-
const hasP = $(li).find('p').length;
|
|
49
|
+
const hasP = $html(li).find('p').length;
|
|
47
50
|
|
|
48
51
|
if (hasP) {
|
|
49
|
-
$(li).html($(li).find('p').html());
|
|
52
|
+
$html(li).html($html(li).find('p').html());
|
|
50
53
|
}
|
|
51
54
|
});
|
|
52
55
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-jekyll-export",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.41",
|
|
4
4
|
"description": "tbc",
|
|
5
5
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-jekyll-export",
|
|
6
6
|
"author": "Ghost Foundation",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"eslint": "8.57.0",
|
|
25
|
-
"jest": "30.0
|
|
26
|
-
"jest-extended": "
|
|
25
|
+
"jest": "30.2.0",
|
|
26
|
+
"jest-extended": "7.0.0"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@tryghost/errors": "1.3.8",
|
|
30
|
-
"@tryghost/mg-fs-utils": "0.16.
|
|
31
|
-
"@tryghost/string": "0.2.
|
|
32
|
-
"cheerio": "1.
|
|
30
|
+
"@tryghost/mg-fs-utils": "0.16.4",
|
|
31
|
+
"@tryghost/string": "0.2.21",
|
|
32
|
+
"cheerio": "1.2.0",
|
|
33
33
|
"front-matter": "4.0.2",
|
|
34
|
-
"markdown-it": "14.1.
|
|
34
|
+
"markdown-it": "14.1.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "ac9a868976ef5963df7fc2426af9e298bd5d8666"
|
|
37
37
|
}
|