@tryghost/mg-medium-export 0.17.27 → 0.17.29
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/lib/process-content.js +78 -78
- package/lib/process-post.js +53 -64
- package/lib/process-profile.js +7 -7
- package/package.json +10 -11
package/lib/process-content.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {domUtils} from '@tryghost/mg-utils';
|
|
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';
|
|
@@ -8,10 +8,10 @@ const doReplace = (str) => {
|
|
|
8
8
|
const replaceParts = [
|
|
9
9
|
[/[\s\n]/g, ''], // Remove spaces
|
|
10
10
|
[/\.$/, ''], // Trim trailing full stop
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[/\u2018/, '\''], // Convert single opening curly quote to straight quote
|
|
12
|
+
[/\u2019/, '\''], // Convert single closing curly quote to straight quote
|
|
13
|
+
[/\u201c/, '"'], // Convert double opening curly quote to straight quote
|
|
14
|
+
[/\u201d/, '"'] // Convert double closing curly quote to straight quote
|
|
15
15
|
];
|
|
16
16
|
|
|
17
17
|
replaceParts.forEach((re) => {
|
|
@@ -28,17 +28,14 @@ const equivalentTitles = (title1, title2) => {
|
|
|
28
28
|
return title1 === title2;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export default ({
|
|
32
|
-
|
|
33
|
-
// Uses default cheerio options (parse5) to decode entities and preserve empty attributes
|
|
34
|
-
const $ = cheerio.load(content.html(), {}, false);
|
|
35
|
-
let $content = $.root();
|
|
31
|
+
export default ({html, post}) => {
|
|
32
|
+
const parsed = domUtils.parseFragment(html);
|
|
36
33
|
|
|
37
34
|
// Detect if post is likely to be a comment. If so, set as draft and add tag
|
|
38
35
|
// Based on being published, content having 1 paragraph, and having no images
|
|
39
|
-
let childrenCount =
|
|
40
|
-
let pCount =
|
|
41
|
-
let imgCount =
|
|
36
|
+
let childrenCount = parsed.body.children.length;
|
|
37
|
+
let pCount = parsed.$('p').length;
|
|
38
|
+
let imgCount = parsed.$('img').length;
|
|
42
39
|
|
|
43
40
|
if (post.data.status === 'published' && childrenCount <= 1 && pCount <= 1 && imgCount === 0) {
|
|
44
41
|
post.data.status = 'draft';
|
|
@@ -53,38 +50,38 @@ export default ({content, post}) => {
|
|
|
53
50
|
|
|
54
51
|
// Medium usually has an hr divider at the very beginning of the content
|
|
55
52
|
// We don't need this so remove it if we find it
|
|
56
|
-
let
|
|
57
|
-
if (
|
|
58
|
-
|
|
53
|
+
let firstSection = parsed.$('.section--first')[0];
|
|
54
|
+
if (firstSection) {
|
|
55
|
+
let firstChild = firstSection.firstElementChild;
|
|
56
|
+
if (firstChild && firstChild.classList.contains('section-divider')) {
|
|
57
|
+
firstChild.remove();
|
|
58
|
+
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// Sometimes Medium has a duplicate header at the beginning of the content
|
|
62
62
|
// Don't need this either so remove it
|
|
63
|
-
let firstTitle =
|
|
64
|
-
if (equivalentTitles(firstTitle.
|
|
65
|
-
|
|
63
|
+
let firstTitle = parsed.$('h1, h2, h3, h4, blockquote')[0];
|
|
64
|
+
if (firstTitle && equivalentTitles(firstTitle.textContent, post.data.title)) {
|
|
65
|
+
firstTitle.remove();
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// Remove the subtitle if it's the same as the excerpt
|
|
69
|
-
|
|
70
|
-
if (equivalentTitles(
|
|
71
|
-
|
|
69
|
+
parsed.$('.graf--subtitle').forEach((el) => {
|
|
70
|
+
if (equivalentTitles(el.textContent, post.data.custom_excerpt)) {
|
|
71
|
+
el.remove();
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
// Convert galleries
|
|
76
|
-
|
|
76
|
+
parsed.$('.section-inner.sectionLayout--outsetRow').forEach((el) => {
|
|
77
77
|
// Check we're only working with a group of <figure> elements
|
|
78
|
-
const children =
|
|
79
|
-
const
|
|
80
|
-
return ell.tagName.toLowerCase();
|
|
81
|
-
}).get();
|
|
82
|
-
const allFigures = childElementTags.every(e => e === 'figure');
|
|
78
|
+
const children = Array.from(el.children);
|
|
79
|
+
const allFigures = children.every(child => child.tagName.toLowerCase() === 'figure');
|
|
83
80
|
|
|
84
81
|
// If it's all figures
|
|
85
82
|
if (allFigures) {
|
|
86
|
-
let
|
|
87
|
-
let caption =
|
|
83
|
+
let figcaption = el.querySelector('figcaption');
|
|
84
|
+
let caption = figcaption ? domUtils.serializeChildren(figcaption).trim() : null;
|
|
88
85
|
|
|
89
86
|
let cardOpts = {
|
|
90
87
|
env: {dom: new SimpleDom.Document()},
|
|
@@ -94,105 +91,108 @@ export default ({content, post}) => {
|
|
|
94
91
|
}
|
|
95
92
|
};
|
|
96
93
|
|
|
97
|
-
|
|
98
|
-
let img =
|
|
94
|
+
el.querySelectorAll('figure').forEach((figure) => { // eslint-disable-line no-shadow
|
|
95
|
+
let img = figure.querySelector('img');
|
|
99
96
|
cardOpts.payload.images.push({
|
|
100
97
|
row: 0,
|
|
101
|
-
fileName: img.
|
|
102
|
-
src: img.
|
|
103
|
-
width: img.
|
|
104
|
-
height: img.
|
|
98
|
+
fileName: img.getAttribute('data-image-id'),
|
|
99
|
+
src: img.getAttribute('src'),
|
|
100
|
+
width: img.getAttribute('data-width'),
|
|
101
|
+
height: img.getAttribute('data-height')
|
|
105
102
|
});
|
|
106
103
|
});
|
|
107
104
|
|
|
108
105
|
const galleryHtml = serializer.serialize(galleryCard.render(cardOpts));
|
|
109
106
|
|
|
110
|
-
|
|
107
|
+
domUtils.replaceWith(el, galleryHtml);
|
|
111
108
|
}
|
|
112
109
|
});
|
|
113
110
|
|
|
114
111
|
// Convert Medium bookmarks
|
|
115
|
-
|
|
112
|
+
parsed.$('.graf--mixtapeEmbed').forEach((el) => {
|
|
116
113
|
let cardOpts = {
|
|
117
114
|
env: {dom: new SimpleDom.Document()},
|
|
118
115
|
payload: {}
|
|
119
116
|
};
|
|
120
117
|
|
|
121
|
-
let href =
|
|
118
|
+
let href = el.querySelector('.markup--anchor')?.getAttribute('href');
|
|
122
119
|
cardOpts.payload.url = href;
|
|
123
120
|
|
|
124
121
|
cardOpts.payload.metadata = {
|
|
125
122
|
url: href,
|
|
126
|
-
title:
|
|
127
|
-
description:
|
|
123
|
+
title: el.querySelector('.markup--strong')?.textContent || '',
|
|
124
|
+
description: el.querySelector('.markup--em')?.textContent || ''
|
|
128
125
|
};
|
|
129
126
|
|
|
130
|
-
const
|
|
127
|
+
const mixtapeImage = el.querySelector('.js-mixtapeImage');
|
|
128
|
+
const bngImage = mixtapeImage ? mixtapeImage.style.backgroundImage : null;
|
|
131
129
|
if (bngImage) {
|
|
132
|
-
let src = bngImage.replace(/url\((.*?)
|
|
130
|
+
let src = bngImage.replace(/url\(["']?(.*?)["']?\)/, (m, p) => p);
|
|
133
131
|
cardOpts.payload.metadata.thumbnail = src;
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
const bookmarkHtml = serializer.serialize(bookmarkCard.render(cardOpts));
|
|
137
135
|
|
|
138
|
-
|
|
136
|
+
domUtils.replaceWith(el, `<!--kg-card-begin: html-->\n${bookmarkHtml}\n<!--kg-card-end: html-->`);
|
|
139
137
|
});
|
|
140
138
|
|
|
141
139
|
// Handle blockquotes made of 2 elements
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
parsed.$('blockquote.graf--pullquote, blockquote.graf--blockquote').forEach((bq) => {
|
|
141
|
+
bq.removeAttribute('name');
|
|
142
|
+
bq.removeAttribute('id');
|
|
143
|
+
bq.removeAttribute('class');
|
|
144
|
+
|
|
145
|
+
bq.querySelectorAll('a').forEach((a) => {
|
|
146
|
+
a.removeAttribute('data-href');
|
|
147
|
+
a.removeAttribute('class');
|
|
150
148
|
});
|
|
151
149
|
|
|
152
150
|
let textElements = [];
|
|
153
|
-
textElements.push(
|
|
151
|
+
textElements.push(domUtils.serializeChildren(bq).trim());
|
|
154
152
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const nextText =
|
|
153
|
+
const nextElem = bq.nextElementSibling;
|
|
154
|
+
if (nextElem && nextElem.matches('.graf-after--pullquote')) {
|
|
155
|
+
const nextText = domUtils.serializeChildren(nextElem);
|
|
158
156
|
if (nextText && nextText.length > 0) {
|
|
159
157
|
textElements.push(nextText.trim());
|
|
160
|
-
|
|
158
|
+
nextElem.remove();
|
|
161
159
|
}
|
|
162
160
|
}
|
|
163
161
|
|
|
164
|
-
|
|
162
|
+
domUtils.replaceWith(bq, `<blockquote><p>${textElements.join('<br><br>')}</p></blockquote>`);
|
|
165
163
|
});
|
|
166
164
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const lang =
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
165
|
+
parsed.$('pre.graf--pre').forEach((pre) => {
|
|
166
|
+
pre.removeAttribute('name');
|
|
167
|
+
pre.removeAttribute('id');
|
|
168
|
+
pre.removeAttribute('class');
|
|
169
|
+
pre.removeAttribute('data-code-block-mode');
|
|
170
|
+
pre.removeAttribute('spellcheck');
|
|
171
|
+
pre.innerHTML = domUtils.serializeChildren(pre).trim();
|
|
172
|
+
|
|
173
|
+
const lang = pre.getAttribute('data-code-block-lang');
|
|
174
|
+
pre.removeAttribute('data-code-block-lang');
|
|
175
|
+
|
|
176
|
+
pre.querySelectorAll('span.pre--content').forEach((span) => {
|
|
177
|
+
const code = parsed.document.createElement('code');
|
|
178
|
+
code.innerHTML = span.innerHTML;
|
|
179
|
+
span.parentNode.replaceChild(code, span);
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
pre.querySelectorAll('code').forEach((code) => {
|
|
183
|
+
code.removeAttribute('name');
|
|
184
|
+
code.removeAttribute('id');
|
|
185
|
+
code.removeAttribute('class');
|
|
186
186
|
|
|
187
187
|
if (lang && lang.length > 0) {
|
|
188
|
-
|
|
188
|
+
code.classList.add(`language-${lang}`);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
code.innerHTML = domUtils.serializeChildren(code).replace(/<br>/g, ' \n').trim();
|
|
192
192
|
});
|
|
193
193
|
});
|
|
194
194
|
|
|
195
|
-
post.data.html =
|
|
195
|
+
post.data.html = parsed.html().trim();
|
|
196
196
|
|
|
197
197
|
return post;
|
|
198
198
|
};
|
package/lib/process-post.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {domUtils} from '@tryghost/mg-utils';
|
|
2
2
|
import string from '@tryghost/string';
|
|
3
3
|
import processContent from './process-content.js';
|
|
4
4
|
|
|
5
5
|
const sectionTags = ['aside', 'blockquote', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'img'];
|
|
6
6
|
|
|
7
|
-
const processMeta = ({name,
|
|
7
|
+
const processMeta = ({name, parsed, options}) => {
|
|
8
8
|
const mediumAsCanonical = options?.mediumAsCanonical ?? false;
|
|
9
9
|
|
|
10
10
|
let urlInfo;
|
|
@@ -12,16 +12,17 @@ const processMeta = ({name, $post, options}) => {
|
|
|
12
12
|
const dateNow = new Date();
|
|
13
13
|
|
|
14
14
|
const post = {
|
|
15
|
-
url:
|
|
15
|
+
url: parsed.$('.p-canonical')[0]?.getAttribute('href'),
|
|
16
16
|
data: {
|
|
17
|
-
title:
|
|
18
|
-
custom_excerpt:
|
|
17
|
+
title: parsed.$('.p-name')[0]?.textContent || '',
|
|
18
|
+
custom_excerpt: (parsed.$('.p-summary')[0]?.textContent || '').trim()
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
if (/^(?:posts\/)?draft/.test(name)) {
|
|
23
23
|
urlInfo = name.match(/_(.*?)-([0-9a-f]+)\.html/);
|
|
24
|
-
|
|
24
|
+
const footerLink = parsed.$('footer p a')[0];
|
|
25
|
+
post.url = footerLink?.getAttribute('href');
|
|
25
26
|
post.data.status = 'draft';
|
|
26
27
|
post.data.created_at = dateNow;
|
|
27
28
|
post.data.updated_at = dateNow;
|
|
@@ -35,23 +36,17 @@ const processMeta = ({name, $post, options}) => {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
post.data.status = 'published';
|
|
38
|
-
|
|
39
|
-
post.data.
|
|
40
|
-
post.data.
|
|
39
|
+
const publishedDatetime = parsed.$('.dt-published')[0]?.getAttribute('datetime');
|
|
40
|
+
post.data.created_at = publishedDatetime || dateNow;
|
|
41
|
+
post.data.published_at = publishedDatetime || dateNow;
|
|
42
|
+
post.data.updated_at = publishedDatetime || dateNow;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
if (mediumAsCanonical) {
|
|
44
|
-
const canonicalUrl =
|
|
46
|
+
const canonicalUrl = parsed.$('.p-canonical')[0]?.getAttribute('href');
|
|
45
47
|
post.data.canonical_url = canonicalUrl;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
// $('img').map(async (i, el) => {
|
|
49
|
-
// let $image = $(el);
|
|
50
|
-
// let type = $image.attr('src') === undefined ? 'data-src' : 'src';
|
|
51
|
-
// let newSrc = await this.downloadImage($image.attr(type));
|
|
52
|
-
// $image.attr(type, newSrc);
|
|
53
|
-
// }).get();
|
|
54
|
-
|
|
55
50
|
// Ensure the slug is clean and valid according to Ghost
|
|
56
51
|
post.data.slug = string.slugify(urlInfo[1]);
|
|
57
52
|
// Store the medium ID in the comment ID legacy field - not sure if this is useful
|
|
@@ -60,12 +55,13 @@ const processMeta = ({name, $post, options}) => {
|
|
|
60
55
|
return post;
|
|
61
56
|
};
|
|
62
57
|
|
|
63
|
-
const processAuthor = ({
|
|
58
|
+
const processAuthor = ({pAuthor}) => {
|
|
59
|
+
const href = pAuthor.getAttribute('href');
|
|
64
60
|
return {
|
|
65
|
-
url:
|
|
61
|
+
url: href,
|
|
66
62
|
data: {
|
|
67
|
-
name:
|
|
68
|
-
slug:
|
|
63
|
+
name: pAuthor.textContent,
|
|
64
|
+
slug: href.replace(/.*?@(.*?)$/, (m, p) => p.toLowerCase()),
|
|
69
65
|
roles: [
|
|
70
66
|
'Contributor'
|
|
71
67
|
]
|
|
@@ -73,44 +69,37 @@ const processAuthor = ({$author}) => {
|
|
|
73
69
|
};
|
|
74
70
|
};
|
|
75
71
|
|
|
76
|
-
const processTags = ({
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
url: $tag.attr('href'),
|
|
72
|
+
const processTags = ({tagLinks}) => {
|
|
73
|
+
return tagLinks.map((tag) => {
|
|
74
|
+
const href = tag.getAttribute('href');
|
|
75
|
+
return {
|
|
76
|
+
url: href,
|
|
82
77
|
data: {
|
|
83
|
-
name:
|
|
84
|
-
slug:
|
|
78
|
+
name: tag.textContent,
|
|
79
|
+
slug: href.replace(/.*\/(.*?)$/, (m, p) => p.toLowerCase())
|
|
85
80
|
}
|
|
86
|
-
}
|
|
81
|
+
};
|
|
87
82
|
});
|
|
88
|
-
return tags;
|
|
89
83
|
};
|
|
90
84
|
|
|
91
85
|
const processFeatureImage = ({html, post, options}) => {
|
|
92
|
-
const
|
|
93
|
-
xml: {
|
|
94
|
-
xmlMode: false,
|
|
95
|
-
decodeEntities: false
|
|
96
|
-
}
|
|
97
|
-
}, false);
|
|
86
|
+
const parsed = domUtils.parseFragment(html);
|
|
98
87
|
|
|
99
88
|
// Look for data-is-featured
|
|
100
|
-
let featured =
|
|
89
|
+
let featured = parsed.$('[data-is-featured]')[0] || null;
|
|
101
90
|
|
|
102
91
|
// Look for an image that appears before content
|
|
103
|
-
let allSections =
|
|
92
|
+
let allSections = parsed.$(sectionTags.join(','));
|
|
104
93
|
let foundImg = false;
|
|
105
94
|
let preImageTags = [];
|
|
106
95
|
|
|
107
|
-
allSections.
|
|
96
|
+
allSections.forEach((el) => {
|
|
108
97
|
if (!foundImg) {
|
|
109
|
-
preImageTags.push(el.tagName);
|
|
98
|
+
preImageTags.push(el.tagName.toLowerCase());
|
|
110
99
|
}
|
|
111
100
|
|
|
112
|
-
if (!foundImg && el.tagName === 'img') {
|
|
113
|
-
|
|
101
|
+
if (!foundImg && el.tagName.toLowerCase() === 'img') {
|
|
102
|
+
foundImg = el;
|
|
114
103
|
}
|
|
115
104
|
});
|
|
116
105
|
|
|
@@ -129,31 +118,29 @@ const processFeatureImage = ({html, post, options}) => {
|
|
|
129
118
|
}
|
|
130
119
|
|
|
131
120
|
if (featured) {
|
|
132
|
-
post.data.feature_image =
|
|
133
|
-
post.data.feature_image_alt =
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
121
|
+
post.data.feature_image = featured.getAttribute('src');
|
|
122
|
+
post.data.feature_image_alt = featured.getAttribute('alt') || null;
|
|
123
|
+
const figure = featured.closest('figure');
|
|
124
|
+
const figcaption = figure ? figure.querySelector('figcaption') : null;
|
|
125
|
+
post.data.feature_image_caption = figcaption ? domUtils.serializeChildren(figcaption).trim() : null;
|
|
126
|
+
|
|
127
|
+
if (figure) {
|
|
128
|
+
figure.remove();
|
|
129
|
+
}
|
|
137
130
|
}
|
|
138
131
|
|
|
139
|
-
return
|
|
132
|
+
return parsed.html().trim();
|
|
140
133
|
};
|
|
141
134
|
|
|
142
135
|
export default ({name, html, globalUser, options}) => {
|
|
143
|
-
const
|
|
144
|
-
xml: {
|
|
145
|
-
xmlMode: false,
|
|
146
|
-
decodeEntities: false,
|
|
147
|
-
scriptingEnabled: false
|
|
148
|
-
}
|
|
149
|
-
}, false); // This `false` is `isDocument`. If `true`, <html>, <head>, and <body> elements are introduced
|
|
136
|
+
const parsed = domUtils.parseFragment(html);
|
|
150
137
|
|
|
151
|
-
let post = processMeta({name,
|
|
138
|
+
let post = processMeta({name, parsed, options});
|
|
152
139
|
|
|
153
140
|
// Process author
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
141
|
+
const pAuthor = parsed.$('.p-author')[0];
|
|
142
|
+
if (pAuthor) {
|
|
143
|
+
post.data.author = processAuthor({pAuthor});
|
|
157
144
|
} else if (globalUser) {
|
|
158
145
|
post.data.author = globalUser;
|
|
159
146
|
}
|
|
@@ -170,8 +157,9 @@ export default ({name, html, globalUser, options}) => {
|
|
|
170
157
|
}
|
|
171
158
|
|
|
172
159
|
// Process tags
|
|
173
|
-
|
|
174
|
-
|
|
160
|
+
const tagLinks = parsed.$('.p-tags a');
|
|
161
|
+
if (tagLinks.length) {
|
|
162
|
+
post.data.tags = [...post.data.tags, ...processTags({tagLinks})];
|
|
175
163
|
}
|
|
176
164
|
|
|
177
165
|
if (options?.addPlatformTag) {
|
|
@@ -184,8 +172,9 @@ export default ({name, html, globalUser, options}) => {
|
|
|
184
172
|
}
|
|
185
173
|
|
|
186
174
|
// Process content
|
|
187
|
-
|
|
188
|
-
|
|
175
|
+
const eContent = parsed.$('.e-content')[0];
|
|
176
|
+
const contentHtml = eContent ? domUtils.serializeChildren(eContent) : '';
|
|
177
|
+
post = processContent({html: contentHtml, post});
|
|
189
178
|
|
|
190
179
|
// Grab the featured image
|
|
191
180
|
// Do this last so that we can add tags to indicate feature image style
|
package/lib/process-profile.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {domUtils} from '@tryghost/mg-utils';
|
|
2
2
|
|
|
3
3
|
// Keys we've seen so far
|
|
4
4
|
// Profile
|
|
@@ -22,20 +22,20 @@ const mediumToGhost = {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export default ({html}) => {
|
|
25
|
-
|
|
25
|
+
const parsed = domUtils.parseFragment(html);
|
|
26
26
|
let profile = {
|
|
27
|
-
url:
|
|
27
|
+
url: parsed.$('.u-url')[0]?.getAttribute('href'),
|
|
28
28
|
data: {
|
|
29
|
-
name:
|
|
30
|
-
profile_image:
|
|
29
|
+
name: parsed.$('.p-name')[0]?.textContent || '',
|
|
30
|
+
profile_image: parsed.$('.u-photo')[0]?.getAttribute('src'),
|
|
31
31
|
roles: [
|
|
32
32
|
'Contributor'
|
|
33
33
|
]
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
let [item, value] =
|
|
37
|
+
parsed.$('ul li').forEach((el) => {
|
|
38
|
+
let [item, value] = el.textContent.split(': ');
|
|
39
39
|
let key = mediumToGhost[item.toLowerCase()] || null;
|
|
40
40
|
|
|
41
41
|
if (key) {
|
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.29",
|
|
4
4
|
"description": "tbc",
|
|
5
5
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-medium-export",
|
|
6
6
|
"author": "Ghost Foundation",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"dev": "echo \"Implement me!\"",
|
|
12
|
-
"test": "
|
|
12
|
+
"test": "c8 --check-coverage --lines 100 --branches 100 --functions 100 --statements 100 node --test 'test/**/*.test.js'",
|
|
13
13
|
"lint": "eslint . --ext .js --cache",
|
|
14
14
|
"posttest": "yarn lint"
|
|
15
15
|
},
|
|
@@ -21,17 +21,16 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"jest-extended": "7.0.0"
|
|
24
|
+
"c8": "11.0.0",
|
|
25
|
+
"eslint": "8.57.1"
|
|
27
26
|
},
|
|
28
27
|
"dependencies": {
|
|
29
|
-
"@tryghost/debug": "0.
|
|
30
|
-
"@tryghost/kg-default-cards": "10.2.
|
|
31
|
-
"@tryghost/mg-fs-utils": "0.16.
|
|
32
|
-
"@tryghost/
|
|
33
|
-
"
|
|
28
|
+
"@tryghost/debug": "2.0.3",
|
|
29
|
+
"@tryghost/kg-default-cards": "10.2.10",
|
|
30
|
+
"@tryghost/mg-fs-utils": "0.16.7",
|
|
31
|
+
"@tryghost/mg-utils": "0.1.2",
|
|
32
|
+
"@tryghost/string": "0.3.1",
|
|
34
33
|
"simple-dom": "1.4.0"
|
|
35
34
|
},
|
|
36
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "dfaf02f58e6598ec4abb56a568eb1b6a65ee12f4"
|
|
37
36
|
}
|