@tryghost/mg-medium-export 0.15.3 → 0.16.0

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 CHANGED
@@ -51,6 +51,12 @@ It's possible to pass more options, in order to achieve a better migration file
51
51
  - **`-e` `--email`**
52
52
  - string - default: `false`
53
53
  - Provide an email domain for users e.g. example.com
54
+ - **`--addTag`**
55
+ - string - default: `null`
56
+ - Provide a tag name which should be added to every post in this migration (Wrap in single quotes if tag name has spaces `'Like This'`)
57
+ - **`--addPlatformTag`**
58
+ - Add #medium tag to migrated content
59
+ - bool - default: `true`
54
60
  - **`--mediumAsCanonical`**
55
61
  - bool - default: `false`
56
62
  - Use medium article as canonical URL
@@ -83,7 +83,7 @@ const processTags = ({$tags}) => {
83
83
  return tags;
84
84
  };
85
85
 
86
- const processFeatureImage = ({html, post}) => {
86
+ const processFeatureImage = ({html, post, options}) => {
87
87
  const $html = $.load(html, {
88
88
  decodeEntities: false
89
89
  }, false);
@@ -109,12 +109,15 @@ const processFeatureImage = ({html, post}) => {
109
109
  // We don't have a designated feature image, but there's an image above the content so use that image instead
110
110
  if (!featured && !preImageTags.includes('p')) {
111
111
  featured = foundImg;
112
- // tag it with #auto-feature-image so we can tell the difference
113
- post.data.tags.push({
114
- data: {
115
- name: '#auto-feature-image'
116
- }
117
- });
112
+
113
+ if (options?.addPlatformTag) {
114
+ // tag it with #auto-feature-image so we can tell the difference
115
+ post.data.tags.push({
116
+ data: {
117
+ name: '#auto-feature-image'
118
+ }
119
+ });
120
+ }
118
121
  }
119
122
 
120
123
  if (featured) {
@@ -146,20 +149,34 @@ export default ({name, html, globalUser, options}) => {
146
149
  post.data.author = globalUser;
147
150
  }
148
151
 
152
+ post.data.tags = [];
153
+
154
+ if (options?.addTag) {
155
+ post.data.tags.push({
156
+ url: 'migrator-added-tag',
157
+ data: {
158
+ name: options.addTag
159
+ }
160
+ });
161
+ }
162
+
149
163
  // Process tags
150
164
  if ($post('.p-tags a').length) {
151
- post.data.tags = processTags({$tags: $post('.p-tags a')});
152
- } else {
153
- post.data.tags = [];
165
+ post.data.tags = [...post.data.tags, ...processTags({$tags: $post('.p-tags a')})];
154
166
  }
155
167
 
156
- post.data.tags.push({
157
- url: 'migrator-added-tag', data: {name: '#medium'}
158
- });
168
+ if (options?.addPlatformTag) {
169
+ post.data.tags.push({
170
+ url: 'migrator-added-platform-tag',
171
+ data: {
172
+ name: '#medium'
173
+ }
174
+ });
175
+ }
159
176
 
160
177
  // Grab the featured image
161
178
  // Do this last so that we can add tags to indicate feature image style
162
- post.data.html = processFeatureImage({html: post.data.html, post});
179
+ post.data.html = processFeatureImage({html: post.data.html, post, options});
163
180
 
164
181
  return post;
165
182
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-medium-export",
3
- "version": "0.15.3",
3
+ "version": "0.16.0",
4
4
  "description": "tbc",
5
5
  "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-medium-export",
6
6
  "author": "Ghost Foundation",
@@ -21,16 +21,16 @@
21
21
  "access": "public"
22
22
  },
23
23
  "devDependencies": {
24
- "eslint": "8.47.0",
25
- "jest": "29.6.2",
26
- "jest-extended": "3.2.4"
24
+ "eslint": "8.50.0",
25
+ "jest": "29.7.0",
26
+ "jest-extended": "4.0.1"
27
27
  },
28
28
  "dependencies": {
29
29
  "@tryghost/debug": "0.1.26",
30
- "@tryghost/mg-fs-utils": "^0.12.15",
30
+ "@tryghost/mg-fs-utils": "^0.12.17",
31
31
  "@tryghost/string": "0.2.8",
32
32
  "cheerio": "1.0.0-rc.12",
33
33
  "date-fns": "2.30.0"
34
34
  },
35
- "gitHead": "0df990176ed00c9076d1bec7ddafa2a6b2ddd967"
35
+ "gitHead": "666a72434beb865a7db4ec4890b0138c535d7d00"
36
36
  }