@tryghost/mg-medium-export 0.17.24 → 0.17.26
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-content.js +5 -2
- package/lib/process-post.js +18 -12
- package/lib/process-profile.js +1 -1
- package/package.json +9 -9
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -44,10 +44,11 @@ It's possible to pass more options, in order to achieve a better migration file
|
|
|
44
44
|
- **`-s` `--scrape`**
|
|
45
45
|
- Configure scraping tasks
|
|
46
46
|
- string - default: `all`
|
|
47
|
-
- Choices: `all`, `
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
- Choices: `all`, `web`, `assets`, `none`
|
|
48
|
+
- `all`: Scrape web metadata and download assets
|
|
49
|
+
- `web`: Only scrape metadata from web pages
|
|
50
|
+
- `assets`: Only download assets (images, media, files)
|
|
51
|
+
- `none`: Skip all scraping tasks
|
|
51
52
|
- **`-e` `--email`**
|
|
52
53
|
- string - default: `false`
|
|
53
54
|
- Provide an email domain for users e.g. example.com
|
|
@@ -102,4 +103,4 @@ yarn dev medium --pathToZip /path/to/my-export.zip
|
|
|
102
103
|
|
|
103
104
|
# Copyright & License
|
|
104
105
|
|
|
105
|
-
Copyright (c) 2013-
|
|
106
|
+
Copyright (c) 2013-2026 Ghost Foundation - Released under the [MIT license](LICENSE).
|
package/lib/process-content.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as cheerio from 'cheerio';
|
|
2
2
|
import SimpleDom from 'simple-dom';
|
|
3
3
|
import galleryCard from '@tryghost/kg-default-cards/lib/cards/gallery.js';
|
|
4
4
|
import bookmarkCard from '@tryghost/kg-default-cards/lib/cards/bookmark.js';
|
|
@@ -29,7 +29,10 @@ const equivalentTitles = (title1, title2) => {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export default ({content, post}) => {
|
|
32
|
-
|
|
32
|
+
// Load the content HTML to get a Cheerio instance we can use
|
|
33
|
+
// Uses default cheerio options (parse5) to decode entities and preserve empty attributes
|
|
34
|
+
const $ = cheerio.load(content.html(), {}, false);
|
|
35
|
+
let $content = $.root();
|
|
33
36
|
|
|
34
37
|
// Detect if post is likely to be a comment. If so, set as draft and add tag
|
|
35
38
|
// Based on being published, content having 1 paragraph, and having no images
|
package/lib/process-post.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as cheerio from 'cheerio';
|
|
2
2
|
import string from '@tryghost/string';
|
|
3
3
|
import processContent from './process-content.js';
|
|
4
4
|
|
|
@@ -75,8 +75,8 @@ const processAuthor = ({$author}) => {
|
|
|
75
75
|
|
|
76
76
|
const processTags = ({$tags}) => {
|
|
77
77
|
const tags = [];
|
|
78
|
-
$tags.each((i
|
|
79
|
-
let $tag = $(
|
|
78
|
+
$tags.each((i) => {
|
|
79
|
+
let $tag = $tags.eq(i);
|
|
80
80
|
tags.push({
|
|
81
81
|
url: $tag.attr('href'),
|
|
82
82
|
data: {
|
|
@@ -89,8 +89,11 @@ const processTags = ({$tags}) => {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
const processFeatureImage = ({html, post, options}) => {
|
|
92
|
-
const $html =
|
|
93
|
-
|
|
92
|
+
const $html = cheerio.load(html, {
|
|
93
|
+
xml: {
|
|
94
|
+
xmlMode: false,
|
|
95
|
+
decodeEntities: false
|
|
96
|
+
}
|
|
94
97
|
}, false);
|
|
95
98
|
|
|
96
99
|
// Look for data-is-featured
|
|
@@ -126,20 +129,23 @@ const processFeatureImage = ({html, post, options}) => {
|
|
|
126
129
|
}
|
|
127
130
|
|
|
128
131
|
if (featured) {
|
|
129
|
-
post.data.feature_image = $(featured).attr('src');
|
|
130
|
-
post.data.feature_image_alt = $(featured).attr('alt') || null;
|
|
131
|
-
post.data.feature_image_caption = $(featured).parents('figure').find('figcaption').html() || null;
|
|
132
|
+
post.data.feature_image = $html(featured).attr('src');
|
|
133
|
+
post.data.feature_image_alt = $html(featured).attr('alt') || null;
|
|
134
|
+
post.data.feature_image_caption = $html(featured).parents('figure').find('figcaption').html() || null;
|
|
132
135
|
|
|
133
|
-
$(featured).parents('figure').remove();
|
|
136
|
+
$html(featured).parents('figure').remove();
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
return $html.html().trim();
|
|
137
140
|
};
|
|
138
141
|
|
|
139
142
|
export default ({name, html, globalUser, options}) => {
|
|
140
|
-
const $post =
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
const $post = cheerio.load(html, {
|
|
144
|
+
xml: {
|
|
145
|
+
xmlMode: false,
|
|
146
|
+
decodeEntities: false,
|
|
147
|
+
scriptingEnabled: false
|
|
148
|
+
}
|
|
143
149
|
}, false); // This `false` is `isDocument`. If `true`, <html>, <head>, and <body> elements are introduced
|
|
144
150
|
|
|
145
151
|
let post = processMeta({name, $post, options});
|
package/lib/process-profile.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-medium-export",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.26",
|
|
4
4
|
"description": "tbc",
|
|
5
5
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-medium-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
|
-
"@tryghost/debug": "0.1.
|
|
30
|
-
"@tryghost/kg-default-cards": "10.2.
|
|
31
|
-
"@tryghost/mg-fs-utils": "0.16.
|
|
32
|
-
"@tryghost/string": "0.2.
|
|
33
|
-
"cheerio": "1.
|
|
29
|
+
"@tryghost/debug": "0.1.36",
|
|
30
|
+
"@tryghost/kg-default-cards": "10.2.6",
|
|
31
|
+
"@tryghost/mg-fs-utils": "0.16.4",
|
|
32
|
+
"@tryghost/string": "0.2.21",
|
|
33
|
+
"cheerio": "1.2.0",
|
|
34
34
|
"simple-dom": "1.4.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "ac9a868976ef5963df7fc2426af9e298bd5d8666"
|
|
37
37
|
}
|