@tryghost/mg-json 0.8.0 → 0.8.4
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/to-ghost-json/process-post-relations.js +25 -4
- package/lib/to-ghost-json/validate.js +25 -0
- package/package.json +8 -8
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = (json) => {
|
|
|
30
30
|
if (!_.has(json, location)) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
return json[location].find((item) => {
|
|
33
|
+
return json[location].find((item) => { // eslint-disable-line array-callback-return
|
|
34
34
|
// @TODO: need to scrape, or post-process scrape for user and tag slugs
|
|
35
35
|
if (item.data.id && item.data.id === match.data.id) {
|
|
36
36
|
return item;
|
|
@@ -91,12 +91,33 @@ module.exports = (json) => {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
const processPostMeta = (postData) => {
|
|
94
|
-
// TODO: Build out this list of meta data
|
|
95
94
|
let postMeta = {
|
|
96
|
-
post_id:
|
|
95
|
+
post_id: postData.id
|
|
97
96
|
};
|
|
98
97
|
|
|
99
|
-
|
|
98
|
+
// List from https://github.com/TryGhost/Ghost/blob/main/core/server/data/schema/schema.js#L63-L79
|
|
99
|
+
const metaKeys = [
|
|
100
|
+
'og_image',
|
|
101
|
+
'og_title',
|
|
102
|
+
'og_description',
|
|
103
|
+
'twitter_image',
|
|
104
|
+
'twitter_title',
|
|
105
|
+
'twitter_description',
|
|
106
|
+
'meta_title',
|
|
107
|
+
'meta_description',
|
|
108
|
+
'email_subject',
|
|
109
|
+
'frontmatter',
|
|
110
|
+
'feature_image_alt',
|
|
111
|
+
'feature_image_caption',
|
|
112
|
+
'email_only'
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
metaKeys.forEach((item) => {
|
|
116
|
+
if (postData[item]) {
|
|
117
|
+
postMeta[item] = postData[item];
|
|
118
|
+
delete postData[item];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
100
121
|
|
|
101
122
|
json.posts_meta.push(postMeta);
|
|
102
123
|
|
|
@@ -2,16 +2,41 @@ module.exports = (json) => {
|
|
|
2
2
|
json.posts.forEach((item, index) => {
|
|
3
3
|
let input = item.data;
|
|
4
4
|
|
|
5
|
+
// String length data from https://github.com/TryGhost/Ghost/blob/main/core/server/data/schema/schema.js
|
|
5
6
|
// @TODO: log some sort of warning for things like this?
|
|
6
7
|
|
|
7
8
|
if (input.custom_excerpt && input.custom_excerpt.length > 300) {
|
|
8
9
|
input.custom_excerpt = input.custom_excerpt.substring(0, 300);
|
|
9
10
|
}
|
|
10
11
|
|
|
12
|
+
if (input.og_title && input.og_title.length > 300) {
|
|
13
|
+
input.og_title = input.og_title.substring(0, 300);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (input.og_description && input.og_description.length > 500) {
|
|
17
|
+
input.og_description = input.og_description.substring(0, 500);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (input.twitter_title && input.twitter_title.length > 300) {
|
|
21
|
+
input.twitter_title = input.twitter_title.substring(0, 300);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (input.twitter_description && input.twitter_description.length > 500) {
|
|
25
|
+
input.twitter_description = input.twitter_description.substring(0, 500);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (input.meta_title && input.meta_title.length > 300) {
|
|
29
|
+
input.meta_title = input.meta_title.substring(0, 300);
|
|
30
|
+
}
|
|
31
|
+
|
|
11
32
|
if (input.meta_description && input.meta_description.length > 500) {
|
|
12
33
|
input.meta_description = input.meta_description.substring(0, 500);
|
|
13
34
|
}
|
|
14
35
|
|
|
36
|
+
if (input.email_subject && input.email_subject.length > 300) {
|
|
37
|
+
input.email_subject = input.email_subject.substring(0, 300);
|
|
38
|
+
}
|
|
39
|
+
|
|
15
40
|
if (input.feature_image_alt && input.feature_image_alt.length > 125) {
|
|
16
41
|
input.feature_image_alt = input.feature_image_alt.substring(0, 125);
|
|
17
42
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-json",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"repository": "https://github.com/TryGhost/migrate/tree/
|
|
3
|
+
"version": "0.8.4",
|
|
4
|
+
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-json",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "index.js",
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"mocha": "
|
|
22
|
+
"mocha": "10.0.0",
|
|
23
23
|
"should": "13.2.3",
|
|
24
|
-
"sinon": "
|
|
24
|
+
"sinon": "14.0.0"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tryghost/string": "0.1.
|
|
28
|
-
"bson-objectid": "2.0.
|
|
29
|
-
"html-entities": "2.3.
|
|
27
|
+
"@tryghost/string": "0.1.25",
|
|
28
|
+
"bson-objectid": "2.0.3",
|
|
29
|
+
"html-entities": "2.3.3",
|
|
30
30
|
"lodash": "4.17.21"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "59b4fceeb91ef34ff1de054a9006f6f2d465fc2b"
|
|
33
33
|
}
|