@tryghost/mg-tinynews 0.10.2 → 0.10.3
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 +2 -2
- package/index.js +1 -1
- package/lib/json-to-html.js +36 -26
- package/lib/mapper.js +64 -40
- package/lib/text.js +9 -10
- package/package.json +4 -8
package/README.md
CHANGED
|
@@ -98,8 +98,8 @@ pnpm dev tinynews [options]
|
|
|
98
98
|
|
|
99
99
|
## Test
|
|
100
100
|
|
|
101
|
-
- `pnpm
|
|
102
|
-
-
|
|
101
|
+
- `pnpm test` runs the package tests
|
|
102
|
+
- Linting and formatting are run from the repo root (`pnpm lint`, `pnpm format`)
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
# Copyright & License
|
package/index.js
CHANGED
package/lib/json-to-html.js
CHANGED
|
@@ -6,12 +6,12 @@ const serializer = new SimpleDom.HTMLSerializer(SimpleDom.voidMap);
|
|
|
6
6
|
const imageCard = cardUtils.getCard('image');
|
|
7
7
|
|
|
8
8
|
// From https://gist.github.com/takien/4077195
|
|
9
|
-
const getYouTubeID =
|
|
9
|
+
const getYouTubeID = url => {
|
|
10
10
|
const arr = url.split(/(vi\/|v%3D|v=|\/v\/|youtu\.be\/|\/embed\/)/);
|
|
11
11
|
return undefined !== arr[2] ? arr[2].split(/[^\w-]/i)[0] : arr[0];
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
const formatChildStyles =
|
|
14
|
+
const formatChildStyles = child => {
|
|
15
15
|
let html = [];
|
|
16
16
|
|
|
17
17
|
if (child?.link) {
|
|
@@ -51,15 +51,15 @@ const formatChildStyles = (child) => {
|
|
|
51
51
|
return html.join('');
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
const EntryList =
|
|
55
|
-
const listTypeEl =
|
|
54
|
+
const EntryList = block => {
|
|
55
|
+
const listTypeEl = block.listType === 'NUMBER' ? 'ol' : 'ul';
|
|
56
56
|
|
|
57
57
|
let html = [];
|
|
58
58
|
|
|
59
59
|
html.push(`<${listTypeEl}>`);
|
|
60
60
|
|
|
61
|
-
block.items.forEach(
|
|
62
|
-
item.children.forEach(
|
|
61
|
+
block.items.forEach(item => {
|
|
62
|
+
item.children.forEach(child => {
|
|
63
63
|
html.push(`<li>${formatChildStyles(child)}</li>`);
|
|
64
64
|
});
|
|
65
65
|
});
|
|
@@ -69,18 +69,18 @@ const EntryList = (block) => {
|
|
|
69
69
|
return html.join('');
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
const EntryText =
|
|
72
|
+
const EntryText = block => {
|
|
73
73
|
return TextNode({node: block});
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
const EntryImage =
|
|
76
|
+
const EntryImage = block => {
|
|
77
77
|
if (block.children.length === 0) {
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
let html = [];
|
|
82
82
|
|
|
83
|
-
block.children.forEach(
|
|
83
|
+
block.children.forEach(child => {
|
|
84
84
|
let cardOpts = {
|
|
85
85
|
env: {dom: new SimpleDom.Document()},
|
|
86
86
|
payload: {
|
|
@@ -100,11 +100,11 @@ const EntryImage = (block) => {
|
|
|
100
100
|
return html.join('');
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
-
const EntryHeading =
|
|
103
|
+
const EntryHeading = block => {
|
|
104
104
|
return TextNode({node: block});
|
|
105
105
|
};
|
|
106
106
|
|
|
107
|
-
const EntryBlockquote =
|
|
107
|
+
const EntryBlockquote = block => {
|
|
108
108
|
if (block.children[0].content.trim() === '') {
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
@@ -113,7 +113,7 @@ const EntryBlockquote = (block) => {
|
|
|
113
113
|
|
|
114
114
|
html.push('<blockquote><p>');
|
|
115
115
|
|
|
116
|
-
block.children.forEach(
|
|
116
|
+
block.children.forEach(child => {
|
|
117
117
|
if (child.content.trim() === '') {
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
@@ -132,13 +132,13 @@ const EntryHorizontalRule = () => {
|
|
|
132
132
|
return html.join('');
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
-
const EntryTwitterEmbed =
|
|
135
|
+
const EntryTwitterEmbed = block => {
|
|
136
136
|
const blockHtml = `<figure class="kg-card kg-embed-card"><blockquote class="twitter-tweet"><a href="${block.link}"></a></blockquote><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></figure>`;
|
|
137
137
|
|
|
138
138
|
return blockHtml;
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
-
const EntryTikTokEmbed =
|
|
141
|
+
const EntryTikTokEmbed = block => {
|
|
142
142
|
const usernameRegexp = new RegExp('(?<username>@[a-zA-Z0-9-_]+)');
|
|
143
143
|
const usernameMatches = block.link.match(usernameRegexp);
|
|
144
144
|
|
|
@@ -152,7 +152,7 @@ const EntryTikTokEmbed = (block) => {
|
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
154
|
|
|
155
|
-
const EntryFacebookEmbed =
|
|
155
|
+
const EntryFacebookEmbed = block => {
|
|
156
156
|
if (block?.html) {
|
|
157
157
|
const blockHtml = `<!--kg-card-begin: html-->${block.html}<!--kg-card-end: html-->`;
|
|
158
158
|
return blockHtml;
|
|
@@ -161,7 +161,7 @@ const EntryFacebookEmbed = (block) => {
|
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
-
const EntryVimeoEmbed =
|
|
164
|
+
const EntryVimeoEmbed = block => {
|
|
165
165
|
const videoIDRegexp = new RegExp('(?<videoID>[0-9]{3,})');
|
|
166
166
|
const videoIDMatches = block.link.match(videoIDRegexp);
|
|
167
167
|
|
|
@@ -174,7 +174,7 @@ const EntryVimeoEmbed = (block) => {
|
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
-
const EntryYoutubeEmbed =
|
|
177
|
+
const EntryYoutubeEmbed = block => {
|
|
178
178
|
const videoID = getYouTubeID(block.link);
|
|
179
179
|
|
|
180
180
|
const blockHtml = `<iframe width="160" height="90" src="https://www.youtube.com/embed/${videoID}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>`;
|
|
@@ -182,32 +182,32 @@ const EntryYoutubeEmbed = (block) => {
|
|
|
182
182
|
return blockHtml;
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
const EntryApplePodcastsEmbed =
|
|
185
|
+
const EntryApplePodcastsEmbed = block => {
|
|
186
186
|
const iframeSrc = block.link.replace('https://podcasts.apple.com', 'https://embed.podcasts.apple.com');
|
|
187
187
|
const blockHtml = `<iframe allow="autoplay *; encrypted-media *; fullscreen *; clipboard-write" frameborder="0" height="450" style="width:100%;max-width:660px;overflow:hidden;border-radius:10px;" sandbox="allow-forms allow-popups allow-same-origin allow-scripts allow-storage-access-by-user-activation allow-top-navigation-by-user-activation" src="${iframeSrc}"></iframe>`;
|
|
188
188
|
|
|
189
189
|
return blockHtml;
|
|
190
190
|
};
|
|
191
191
|
|
|
192
|
-
const EntryInstagramPostEmbed =
|
|
192
|
+
const EntryInstagramPostEmbed = block => {
|
|
193
193
|
const blockHtml = `<iframe src="${block.link}embed/captioned/" class="instagram-media" allowtransparency="true" allowfullscreen="true" frameborder="0" scrolling="no" style="background: white; max-width: 658px; width: calc(100% - 2px); border-radius: 3px; border: 1px solid rgb(219, 219, 219); box-shadow: none; display: block; margin: 0px; min-width: 326px; padding: 0px;"></iframe><script async="" src="//www.instagram.com/embed.js"></script>`;
|
|
194
194
|
|
|
195
195
|
return blockHtml;
|
|
196
196
|
};
|
|
197
197
|
|
|
198
|
-
const EntryInstagramReelEmbed =
|
|
198
|
+
const EntryInstagramReelEmbed = block => {
|
|
199
199
|
const blockHtml = `<iframe class="instagram-media" src="${block.link}embed/captioned/" allowtransparency="true" allowfullscreen="true" frameborder="0" scrolling="no" style="background: white; max-width: 540px; width: calc(100% - 2px); border-radius: 3px; border: 1px solid rgb(219, 219, 219); box-shadow: none; display: block; margin: 0px; min-width: 326px; padding: 0px; position: relative;"></iframe><script async="" src="//www.instagram.com/embed.js"></script>`;
|
|
200
200
|
|
|
201
201
|
return blockHtml;
|
|
202
202
|
};
|
|
203
203
|
|
|
204
|
-
const EntryGoogleDocsEmbed =
|
|
204
|
+
const EntryGoogleDocsEmbed = block => {
|
|
205
205
|
const blockHtml = `<iframe class="googledocs-embed" src="${block.link}" allowtransparency="true" allowfullscreen="true" frameborder="0" style="width: 100%; height: 500px;"></iframe>`;
|
|
206
206
|
|
|
207
207
|
return blockHtml;
|
|
208
208
|
};
|
|
209
209
|
|
|
210
|
-
const EntrySpotifyEmbed =
|
|
210
|
+
const EntrySpotifyEmbed = block => {
|
|
211
211
|
let embedUrl = block.link.replace('https://open.spotify.com/episode/', 'https://open.spotify.com/embed/episode/');
|
|
212
212
|
embedUrl = embedUrl.replace('https://open.spotify.com/show/', 'https://open.spotify.com/embed/show/');
|
|
213
213
|
const blockHtml = `<iframe src="${embedUrl}" width="300" height="380" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>`;
|
|
@@ -215,14 +215,14 @@ const EntrySpotifyEmbed = (block) => {
|
|
|
215
215
|
return blockHtml;
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
-
const jsonToHtml =
|
|
218
|
+
const jsonToHtml = blocks => {
|
|
219
219
|
let html = [];
|
|
220
220
|
|
|
221
221
|
if (typeof blocks === 'string') {
|
|
222
222
|
return blocks;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
blocks.forEach(
|
|
225
|
+
blocks.forEach(block => {
|
|
226
226
|
const itemType = block.type ?? null;
|
|
227
227
|
const itemStyle = block.style ?? null;
|
|
228
228
|
|
|
@@ -233,7 +233,14 @@ const jsonToHtml = (blocks) => {
|
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
if (itemType === 'text') {
|
|
236
|
-
if (
|
|
236
|
+
if (
|
|
237
|
+
itemStyle === 'TITLE' ||
|
|
238
|
+
itemStyle === 'SUBTITLE' ||
|
|
239
|
+
itemStyle === 'HEADING_1' ||
|
|
240
|
+
itemStyle === 'HEADING_2' ||
|
|
241
|
+
itemStyle === 'HEADING_3' ||
|
|
242
|
+
itemStyle === 'HEADING_4'
|
|
243
|
+
) {
|
|
237
244
|
html.push(EntryHeading(block));
|
|
238
245
|
} else if (itemStyle === 'NORMAL_TEXT') {
|
|
239
246
|
html.push(EntryText(block));
|
|
@@ -268,7 +275,10 @@ const jsonToHtml = (blocks) => {
|
|
|
268
275
|
html.push(EntryYoutubeEmbed(block));
|
|
269
276
|
} else if (embedHost === 'podcasts.apple.com') {
|
|
270
277
|
html.push(EntryApplePodcastsEmbed(block));
|
|
271
|
-
} else if (
|
|
278
|
+
} else if (
|
|
279
|
+
embedHost === 'open.spotify.com' &&
|
|
280
|
+
(embedPath.startsWith('/episode/') || embedPath.startsWith('/show/'))
|
|
281
|
+
) {
|
|
272
282
|
html.push(EntrySpotifyEmbed(block));
|
|
273
283
|
} else if (embedHost === 'www.instagram.com' && embedPath.startsWith('/p/')) {
|
|
274
284
|
html.push(EntryInstagramPostEmbed(block));
|
package/lib/mapper.js
CHANGED
|
@@ -7,7 +7,7 @@ import {jsonToHtml} from './json-to-html.js';
|
|
|
7
7
|
|
|
8
8
|
const debug = debugFactory('migrate:tinynews:lib:mapper');
|
|
9
9
|
|
|
10
|
-
const textOnly =
|
|
10
|
+
const textOnly = htmlContent => {
|
|
11
11
|
const cleanedContent = sanitizeHtml(htmlContent, {
|
|
12
12
|
allowedTags: [],
|
|
13
13
|
allowedAttributes: {}
|
|
@@ -18,7 +18,7 @@ const textOnly = (htmlContent) => {
|
|
|
18
18
|
const processAuthor = (author, authorsData) => {
|
|
19
19
|
const name = [author.first_names, author.last_name].join(' ').trim();
|
|
20
20
|
const slug = slugify(name);
|
|
21
|
-
const email =
|
|
21
|
+
const email = author?.email && author.email.length > 0 ? author.email : `${slug}@example.com`;
|
|
22
22
|
|
|
23
23
|
let authorObject = {
|
|
24
24
|
url: `/author/${slug}`,
|
|
@@ -40,7 +40,7 @@ const processAuthor = (author, authorsData) => {
|
|
|
40
40
|
// If we have a global authorsData object
|
|
41
41
|
if (authorsData?.data) {
|
|
42
42
|
// Find th author by first & last name
|
|
43
|
-
const thisAuthorInfo = authorsData.data.authors.find(
|
|
43
|
+
const thisAuthorInfo = authorsData.data.authors.find(filterAuthor => {
|
|
44
44
|
return filterAuthor.first_names === author.first_names && filterAuthor.last_name === author.last_name;
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -55,7 +55,7 @@ const processAuthor = (author, authorsData) => {
|
|
|
55
55
|
return authorObject;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
const mapPostPageConfig =
|
|
58
|
+
const mapPostPageConfig = args => {
|
|
59
59
|
const {postData, authorsData, postType} = args;
|
|
60
60
|
|
|
61
61
|
debug(`Mapping data for ${postData.slug}`);
|
|
@@ -70,7 +70,7 @@ const mapPostPageConfig = (args) => {
|
|
|
70
70
|
updated_at: postData.translations[0].last_published_at ?? dateNow,
|
|
71
71
|
created_at: postData.translations[0].first_published_at ?? dateNow,
|
|
72
72
|
title: postData.translations[0].headline,
|
|
73
|
-
type:
|
|
73
|
+
type: postType === 'page' ? 'page' : 'post',
|
|
74
74
|
html: null,
|
|
75
75
|
status: postData.translations[0].published ? 'published' : 'draft',
|
|
76
76
|
og_title: postData.translations[0].facebook_title ?? null,
|
|
@@ -90,7 +90,8 @@ const mapPostPageConfig = (args) => {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
if (mappedData.data.html.includes('class="fb-post')) {
|
|
93
|
-
mappedData.data.codeinjection_head =
|
|
93
|
+
mappedData.data.codeinjection_head =
|
|
94
|
+
'<div id="fb-root"></div><script async defer src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.2"></script>';
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
if (postData?.translations[0].main_image?.children && postData?.translations[0].main_image?.children[0]?.imageUrl) {
|
|
@@ -101,7 +102,7 @@ const mapPostPageConfig = (args) => {
|
|
|
101
102
|
|
|
102
103
|
// Handle mainImage from pages (its in the content object)
|
|
103
104
|
if (postType === 'page' && typeof postData.translations[0].content === 'object') {
|
|
104
|
-
const hasMainImageInContent = postData.translations[0].content.find(
|
|
105
|
+
const hasMainImageInContent = postData.translations[0].content.find(block => {
|
|
105
106
|
return block.type === 'mainImage';
|
|
106
107
|
});
|
|
107
108
|
if (hasMainImageInContent?.children[0]?.imageUrl) {
|
|
@@ -154,7 +155,7 @@ const mapPostPageConfig = (args) => {
|
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
if (postData.tags) {
|
|
157
|
-
postData.tags.forEach(
|
|
158
|
+
postData.tags.forEach(tag => {
|
|
158
159
|
const tagData = tag.tag;
|
|
159
160
|
const tagPublished = tagData.published;
|
|
160
161
|
let tagName = tagData.tag_translations[0].title;
|
|
@@ -186,11 +187,30 @@ const mapPostPageConfig = (args) => {
|
|
|
186
187
|
return mappedData;
|
|
187
188
|
};
|
|
188
189
|
|
|
189
|
-
const processNewsletterContent = (html, options) => {
|
|
190
|
+
const processNewsletterContent = (html, options) => {
|
|
191
|
+
// eslint-disable-line no-unused-vars
|
|
190
192
|
const cleanedContent = sanitizeHtml(html, {
|
|
191
193
|
allowedTags: [
|
|
192
|
-
'b',
|
|
193
|
-
'
|
|
194
|
+
'b',
|
|
195
|
+
'i',
|
|
196
|
+
'em',
|
|
197
|
+
'strong',
|
|
198
|
+
'a',
|
|
199
|
+
'p',
|
|
200
|
+
'br',
|
|
201
|
+
'ul',
|
|
202
|
+
'ol',
|
|
203
|
+
'li',
|
|
204
|
+
'blockquote',
|
|
205
|
+
'figure',
|
|
206
|
+
'figcaption',
|
|
207
|
+
'img',
|
|
208
|
+
'h1',
|
|
209
|
+
'h2',
|
|
210
|
+
'h3',
|
|
211
|
+
'h4',
|
|
212
|
+
'h5',
|
|
213
|
+
'h6',
|
|
194
214
|
'div'
|
|
195
215
|
],
|
|
196
216
|
allowedAttributes: {
|
|
@@ -198,12 +218,12 @@ const processNewsletterContent = (html, options) => { // eslint-disable-line no-
|
|
|
198
218
|
img: ['src', 'alt', 'title']
|
|
199
219
|
},
|
|
200
220
|
transformTags: {
|
|
201
|
-
|
|
221
|
+
div: 'p' // eslint-disable-line quote-props
|
|
202
222
|
}
|
|
203
223
|
});
|
|
204
224
|
|
|
205
|
-
const cleanedHTML = domUtils.processFragment(cleanedContent,
|
|
206
|
-
parsed.$('p').forEach(
|
|
225
|
+
const cleanedHTML = domUtils.processFragment(cleanedContent, parsed => {
|
|
226
|
+
parsed.$('p').forEach(el => {
|
|
207
227
|
const innerHtml = domUtils.serializeChildren(el).trim();
|
|
208
228
|
if (!innerHtml.length || innerHtml === '<br>' || innerHtml === '<br/>') {
|
|
209
229
|
el.remove();
|
|
@@ -211,7 +231,7 @@ const processNewsletterContent = (html, options) => { // eslint-disable-line no-
|
|
|
211
231
|
});
|
|
212
232
|
|
|
213
233
|
// :contains is a jQuery-specific selector, so filter manually
|
|
214
|
-
parsed.$('a').forEach(
|
|
234
|
+
parsed.$('a').forEach(el => {
|
|
215
235
|
if ((el.textContent || '').includes('Made with Letterhead')) {
|
|
216
236
|
el.remove();
|
|
217
237
|
}
|
|
@@ -223,7 +243,8 @@ const processNewsletterContent = (html, options) => { // eslint-disable-line no-
|
|
|
223
243
|
return `<!--kg-card-begin: html-->${cleanedHTML}<!--kg-card-end: html-->`;
|
|
224
244
|
};
|
|
225
245
|
|
|
226
|
-
const mapNewsletterConfig =
|
|
246
|
+
const mapNewsletterConfig = args => {
|
|
247
|
+
// eslint-disable-line no-unused-vars
|
|
227
248
|
const {postData, options} = args;
|
|
228
249
|
|
|
229
250
|
debug(`Mapping data for ${postData.slug}`);
|
|
@@ -277,7 +298,7 @@ const mapNewsletterConfig = (args) => { // eslint-disable-line no-unused-vars
|
|
|
277
298
|
return mappedData;
|
|
278
299
|
};
|
|
279
300
|
|
|
280
|
-
const mapContent = async
|
|
301
|
+
const mapContent = async args => {
|
|
281
302
|
const {options} = args;
|
|
282
303
|
const {articles, pages, newsletters, authors} = options;
|
|
283
304
|
|
|
@@ -297,13 +318,15 @@ const mapContent = async (args) => {
|
|
|
297
318
|
const articlesJSONString = await readFile(articles, 'utf8');
|
|
298
319
|
const articlesJSON = JSON.parse(articlesJSONString);
|
|
299
320
|
|
|
300
|
-
await articlesJSON.forEach(
|
|
301
|
-
output.posts.push(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
321
|
+
await articlesJSON.forEach(data => {
|
|
322
|
+
output.posts.push(
|
|
323
|
+
mapPostPageConfig({
|
|
324
|
+
postData: data,
|
|
325
|
+
authorsData: authorDataJSON,
|
|
326
|
+
postType: 'post',
|
|
327
|
+
options
|
|
328
|
+
})
|
|
329
|
+
);
|
|
307
330
|
});
|
|
308
331
|
}
|
|
309
332
|
|
|
@@ -312,13 +335,15 @@ const mapContent = async (args) => {
|
|
|
312
335
|
const pagesJSONString = await readFile(pages, 'utf8');
|
|
313
336
|
const pagesJSON = JSON.parse(pagesJSONString);
|
|
314
337
|
|
|
315
|
-
await pagesJSON.forEach(
|
|
316
|
-
output.posts.push(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
338
|
+
await pagesJSON.forEach(data => {
|
|
339
|
+
output.posts.push(
|
|
340
|
+
mapPostPageConfig({
|
|
341
|
+
postData: data,
|
|
342
|
+
authorsData: authorDataJSON,
|
|
343
|
+
postType: 'page',
|
|
344
|
+
options
|
|
345
|
+
})
|
|
346
|
+
);
|
|
322
347
|
});
|
|
323
348
|
}
|
|
324
349
|
|
|
@@ -327,18 +352,17 @@ const mapContent = async (args) => {
|
|
|
327
352
|
const newslettersJSONString = await readFile(newsletters, 'utf8');
|
|
328
353
|
const newslettersJSON = JSON.parse(newslettersJSONString);
|
|
329
354
|
|
|
330
|
-
await newslettersJSON.data.newsletter_editions.forEach(
|
|
331
|
-
output.posts.push(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
355
|
+
await newslettersJSON.data.newsletter_editions.forEach(data => {
|
|
356
|
+
output.posts.push(
|
|
357
|
+
mapNewsletterConfig({
|
|
358
|
+
postData: data,
|
|
359
|
+
options
|
|
360
|
+
})
|
|
361
|
+
);
|
|
335
362
|
});
|
|
336
363
|
}
|
|
337
364
|
|
|
338
365
|
return output;
|
|
339
366
|
};
|
|
340
367
|
|
|
341
|
-
export {
|
|
342
|
-
mapPostPageConfig,
|
|
343
|
-
mapContent
|
|
344
|
-
};
|
|
368
|
+
export {mapPostPageConfig, mapContent};
|
package/lib/text.js
CHANGED
|
@@ -8,13 +8,13 @@ const TextNode = ({node}) => {
|
|
|
8
8
|
// If the next node/child starts with one of the punctuation marks above, don't add a space
|
|
9
9
|
if (
|
|
10
10
|
(nextChild &&
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
nextChild.content &&
|
|
12
|
+
nextChild.content[0] &&
|
|
13
|
+
supportedPunctuation.includes(nextChild.content[0])) ||
|
|
14
14
|
(child &&
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
child.content &&
|
|
16
|
+
child.content.slice(-1) &&
|
|
17
|
+
supportedTrailingPunctuation.includes(child.content.slice(-1)))
|
|
18
18
|
) {
|
|
19
19
|
delimiterSpaceChar = '';
|
|
20
20
|
}
|
|
@@ -27,7 +27,8 @@ const TextNode = ({node}) => {
|
|
|
27
27
|
child.content.trim().length === 0 &&
|
|
28
28
|
nextChild &&
|
|
29
29
|
nextChild.content &&
|
|
30
|
-
nextChild.content.trim().length !== 0
|
|
30
|
+
nextChild.content.trim().length !== 0
|
|
31
|
+
) {
|
|
31
32
|
text = '<br />';
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -91,6 +92,4 @@ const TextNode = ({node}) => {
|
|
|
91
92
|
return wrapper;
|
|
92
93
|
};
|
|
93
94
|
|
|
94
|
-
export {
|
|
95
|
-
TextNode
|
|
96
|
-
};
|
|
95
|
+
export {TextNode};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-tinynews",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/TryGhost/migrate.git",
|
|
@@ -17,20 +17,16 @@
|
|
|
17
17
|
"publishConfig": {
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"eslint": "8.57.1"
|
|
22
|
-
},
|
|
20
|
+
"devDependencies": {},
|
|
23
21
|
"dependencies": {
|
|
24
22
|
"@tryghost/debug": "2.2.3",
|
|
25
23
|
"@tryghost/string": "0.3.5",
|
|
26
24
|
"sanitize-html": "2.17.5",
|
|
27
25
|
"simple-dom": "1.4.0",
|
|
28
|
-
"@tryghost/mg-utils": "0.11.
|
|
26
|
+
"@tryghost/mg-utils": "0.11.3"
|
|
29
27
|
},
|
|
30
28
|
"scripts": {
|
|
31
29
|
"dev": "echo \"Implement me!\"",
|
|
32
|
-
"test": "node --test 'test/**/*.test.js'"
|
|
33
|
-
"posttest": "pnpm lint",
|
|
34
|
-
"lint": "eslint . --ext .js --cache"
|
|
30
|
+
"test": "node --test 'test/**/*.test.js'"
|
|
35
31
|
}
|
|
36
32
|
}
|