@tryghost/mg-medium-export 0.17.24 → 0.17.25
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 +1 -1
- package/lib/process-content.js +5 -2
- package/lib/process-post.js +18 -12
- package/lib/process-profile.js +1 -1
- package/package.json +6 -6
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -102,4 +102,4 @@ yarn dev medium --pathToZip /path/to/my-export.zip
|
|
|
102
102
|
|
|
103
103
|
# Copyright & License
|
|
104
104
|
|
|
105
|
-
Copyright (c) 2013-
|
|
105
|
+
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.25",
|
|
4
4
|
"description": "tbc",
|
|
5
5
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-medium-export",
|
|
6
6
|
"author": "Ghost Foundation",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@tryghost/debug": "0.1.35",
|
|
30
|
-
"@tryghost/kg-default-cards": "10.2.
|
|
31
|
-
"@tryghost/mg-fs-utils": "0.16.
|
|
32
|
-
"@tryghost/string": "0.2.
|
|
33
|
-
"cheerio": "1.
|
|
30
|
+
"@tryghost/kg-default-cards": "10.2.3",
|
|
31
|
+
"@tryghost/mg-fs-utils": "0.16.3",
|
|
32
|
+
"@tryghost/string": "0.2.21",
|
|
33
|
+
"cheerio": "1.1.2",
|
|
34
34
|
"simple-dom": "1.4.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "027225930710c0643603f6ae346dc76504d9bb7a"
|
|
37
37
|
}
|