@tryghost/mg-substack 0.6.3 → 0.6.5
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/mapper.js +8 -14
- package/package.json +6 -7
package/lib/mapper.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {formatISO, parseISO, isBefore, isAfter, add} from 'date-fns';
|
|
2
1
|
import _ from 'lodash';
|
|
3
2
|
import errors from '@tryghost/errors';
|
|
4
3
|
import {slugify} from '@tryghost/string';
|
|
@@ -11,8 +10,7 @@ const mapConfig = (data, options) => {
|
|
|
11
10
|
const {url, email, useMetaAuthor, addTag, addPlatformTag, addTypeTag, addAccessTag} = options;
|
|
12
11
|
const slug = data.post_id.replace(/^(?:\d{1,10}\.)(\S*)/gm, '$1');
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
const dateNow = formatISO(new Date());
|
|
13
|
+
const dateNow = new Date();
|
|
16
14
|
|
|
17
15
|
const typeSlug = slugify(data.type);
|
|
18
16
|
const visibilitySlug = slugify(data.audience);
|
|
@@ -166,34 +164,30 @@ export default async (input, options) => {
|
|
|
166
164
|
}
|
|
167
165
|
|
|
168
166
|
if (options.postsBefore && options.postsAfter) {
|
|
169
|
-
const startDate =
|
|
170
|
-
const endDate =
|
|
171
|
-
days: 1
|
|
172
|
-
});
|
|
167
|
+
const startDate = new Date(options.postsAfter);
|
|
168
|
+
const endDate = new Date(new Date(options.postsBefore).setDate(new Date(options.postsBefore).getDate() + 1));
|
|
173
169
|
debug(`Getting posts between ${startDate} and ${endDate}`);
|
|
174
170
|
|
|
175
171
|
await input.forEach((data) => {
|
|
176
|
-
if (
|
|
172
|
+
if ((new Date(data.post_date) > startDate) && (new Date(data.post_date) < endDate)) {
|
|
177
173
|
output.posts.push(mapConfig(data, options));
|
|
178
174
|
}
|
|
179
175
|
});
|
|
180
176
|
} else if (options.postsAfter) {
|
|
181
|
-
const startDate =
|
|
177
|
+
const startDate = new Date(options.postsAfter);
|
|
182
178
|
debug(`Getting posts after ${startDate}`);
|
|
183
179
|
|
|
184
180
|
await input.forEach((data) => {
|
|
185
|
-
if (
|
|
181
|
+
if ((new Date(data.post_date) > startDate)) {
|
|
186
182
|
output.posts.push(mapConfig(data, options));
|
|
187
183
|
}
|
|
188
184
|
});
|
|
189
185
|
} else if (options.postsBefore) {
|
|
190
|
-
const endDate =
|
|
191
|
-
days: 1
|
|
192
|
-
});
|
|
186
|
+
const endDate = new Date(new Date(options.postsBefore).setDate(new Date(options.postsBefore).getDate() + 1));
|
|
193
187
|
debug(`Getting posts until ${endDate}`);
|
|
194
188
|
|
|
195
189
|
await input.forEach((data) => {
|
|
196
|
-
if (
|
|
190
|
+
if (new Date(data.post_date) < endDate) {
|
|
197
191
|
output.posts.push(mapConfig(data, options));
|
|
198
192
|
}
|
|
199
193
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-substack",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-substack",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,18 +25,17 @@
|
|
|
25
25
|
"jest-extended": "4.0.2"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tryghost/debug": "0.1.
|
|
29
|
-
"@tryghost/errors": "1.3.
|
|
30
|
-
"@tryghost/kg-default-cards": "10.0.
|
|
31
|
-
"@tryghost/mg-fs-utils": "0.
|
|
28
|
+
"@tryghost/debug": "0.1.32",
|
|
29
|
+
"@tryghost/errors": "1.3.5",
|
|
30
|
+
"@tryghost/kg-default-cards": "10.0.9",
|
|
31
|
+
"@tryghost/mg-fs-utils": "0.15.0",
|
|
32
32
|
"@tryghost/string": "0.2.12",
|
|
33
33
|
"cheerio": "1.0.0-rc.12",
|
|
34
|
-
"date-fns": "2.30.0",
|
|
35
34
|
"he": "1.2.0",
|
|
36
35
|
"html-entities": "2.5.2",
|
|
37
36
|
"lodash": "4.17.21",
|
|
38
37
|
"simple-dom": "1.4.0",
|
|
39
38
|
"srcset": "5.0.1"
|
|
40
39
|
},
|
|
41
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "c1d13ccea270adcaf60dfc9d1e371ef25dfad31e"
|
|
42
41
|
}
|