@tryghost/mg-medium-export 0.17.7 → 0.17.8

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
@@ -60,9 +60,6 @@ It's possible to pass more options, in order to achieve a better migration file
60
60
  - **`--mediumAsCanonical`**
61
61
  - bool - default: `false`
62
62
  - Use medium article as canonical URL
63
- - **`--removeResponses`**
64
- - bool - default: `true`
65
- - Remove response posts such as comments from the output
66
63
  - **`--fallBackHTMLCard`**
67
64
  - bool - default: `true`
68
65
  - Fall back to convert to HTMLCard, if standard Mobiledoc convert fails
@@ -31,6 +31,23 @@ const equivalentTitles = (title1, title2) => {
31
31
  export default ({content, post}) => {
32
32
  let $content = $(content);
33
33
 
34
+ // Detect if post is likely to be a comment. If so, set as draft and add tag
35
+ // Based on being published, content having 1 paragraph, and having no images
36
+ let childrenCount = $content.children().length;
37
+ let pCount = $content.find('p').length;
38
+ let imgCount = $content.find('img').length;
39
+
40
+ if (post.data.status === 'published' && childrenCount <= 1 && pCount <= 1 && imgCount === 0) {
41
+ post.data.status = 'draft';
42
+ post.data.tags.push({
43
+ url: 'migrator-added-medium-possible-comment',
44
+ data: {
45
+ name: '#Medium Possible Comment',
46
+ slug: 'hash-medium-possible-comment'
47
+ }
48
+ });
49
+ }
50
+
34
51
  // Medium usually has an hr divider at the very beginning of the content
35
52
  // We don't need this so remove it if we find it
36
53
  let $firstSection = $content.find('.section--first');
@@ -172,5 +189,7 @@ export default ({content, post}) => {
172
189
  });
173
190
  });
174
191
 
175
- return $content.html().trim();
192
+ post.data.html = $content.html().trim();
193
+
194
+ return post;
176
195
  };
@@ -135,10 +135,7 @@ export default ({name, html, globalUser, options}) => {
135
135
  scriptingEnabled: false
136
136
  }, false); // This `false` is `isDocument`. If `true`, <html>, <head>, and <body> elements are introduced
137
137
 
138
- const post = processMeta({name, $post, options});
139
-
140
- // Process content
141
- post.data.html = processContent({content: $post('.e-content'), post});
138
+ let post = processMeta({name, $post, options});
142
139
 
143
140
  // Process author
144
141
  if ($post('.p-author').length) {
@@ -173,6 +170,10 @@ export default ({name, html, globalUser, options}) => {
173
170
  });
174
171
  }
175
172
 
173
+ // Process content
174
+ // post.data.html = processContent({content: $post('.e-content'), post});
175
+ post = processContent({content: $post('.e-content'), post});
176
+
176
177
  // Grab the featured image
177
178
  // Do this last so that we can add tags to indicate feature image style
178
179
  post.data.html = processFeatureImage({html: post.data.html, post, options});
package/lib/read-zip.js CHANGED
@@ -17,8 +17,6 @@ const contentStats = async (zipPath) => {
17
17
  };
18
18
 
19
19
  const readMediumZip = ({content, zipPath, options, skippedFileCount}) => {
20
- const {removeResponses} = options;
21
-
22
20
  fsUtils.zip.read(zipPath, (entryName, zipEntry) => {
23
21
  const entryHtml = zipEntry.getData().toString('utf8');
24
22
 
@@ -28,10 +26,6 @@ const readMediumZip = ({content, zipPath, options, skippedFileCount}) => {
28
26
 
29
27
  // Catch all HTML files in `posts/`
30
28
  } else if (/^posts\/.*\.html$/.test(entryName)) {
31
- if (removeResponses && !entryHtml.includes('graf--title')) {
32
- return;
33
- }
34
-
35
29
  content.posts.push({
36
30
  name: entryName,
37
31
  html: entryHtml
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-medium-export",
3
- "version": "0.17.7",
3
+ "version": "0.17.8",
4
4
  "description": "tbc",
5
5
  "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-medium-export",
6
6
  "author": "Ghost Foundation",
@@ -26,12 +26,12 @@
26
26
  "jest-extended": "4.0.2"
27
27
  },
28
28
  "dependencies": {
29
- "@tryghost/debug": "0.1.27",
30
- "@tryghost/kg-default-cards": "10.0.3",
31
- "@tryghost/mg-fs-utils": "^0.14.0",
32
- "@tryghost/string": "0.2.11",
29
+ "@tryghost/debug": "0.1.30",
30
+ "@tryghost/kg-default-cards": "10.0.5",
31
+ "@tryghost/mg-fs-utils": "0.14.1",
32
+ "@tryghost/string": "0.2.12",
33
33
  "cheerio": "1.0.0-rc.12",
34
34
  "simple-dom": "1.4.0"
35
35
  },
36
- "gitHead": "78b8167b57a73027502c925ee5e2e360b8392bc1"
36
+ "gitHead": "f824cede3d1123defe3e4575536dd579984f7fe2"
37
37
  }