@tryghost/mg-substack 1.1.0 → 1.3.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/lib/mapper.js CHANGED
@@ -22,6 +22,7 @@ const mapConfig = (data, options) => {
22
22
  substackData: data,
23
23
  data: {
24
24
  slug: slug,
25
+ comment_id: data.post_id.replace(/\..*$/, ''),
25
26
  published_at: data.post_date || dateNow,
26
27
  updated_at: data.post_date || dateNow,
27
28
  created_at: data.post_date || dateNow,
package/lib/process.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {promises as fs} from 'node:fs';
2
2
  import {join, basename} from 'node:path';
3
3
  import url from 'node:url';
4
- import {domUtils} from '@tryghost/mg-utils';
4
+ import {domUtils, stringUtils} from '@tryghost/mg-utils';
5
5
  import errors from '@tryghost/errors';
6
6
  import SimpleDom from 'simple-dom';
7
7
  import imageCard from '@tryghost/kg-default-cards/lib/cards/image.js';
@@ -13,10 +13,11 @@ import {decode} from 'html-entities';
13
13
  import {parseSrcset} from 'srcset';
14
14
  import {_base as debugFactory} from '@tryghost/debug';
15
15
  import {slugify} from '@tryghost/string';
16
- import _ from 'lodash';
17
16
 
18
17
  const {parseFragment, serializeChildren, replaceWith, insertBefore, insertAfter, attr, parents} = domUtils;
19
18
 
19
+ const {startCase} = stringUtils;
20
+
20
21
  const serializer = new SimpleDom.HTMLSerializer(SimpleDom.voidMap);
21
22
  const debug = debugFactory('migrate:substack:process');
22
23
 
@@ -486,6 +487,25 @@ const processContent = (post, siteUrl, options) => {
486
487
  el.remove();
487
488
  });
488
489
 
490
+ parsed.$('.mention-wrap').forEach((el) => {
491
+ const attrsRaw = attr(el, 'data-attrs');
492
+
493
+ let attrs;
494
+
495
+ try {
496
+ attrs = JSON.parse(attrsRaw);
497
+ } catch (error) {
498
+ return;
499
+ }
500
+
501
+ const name = attrs.name;
502
+ const id = attrs.id;
503
+
504
+ if (name && id) {
505
+ replaceWith(el, `<a href="https://open.substack.com/users/${id}">${name}</a>`);
506
+ }
507
+ });
508
+
489
509
  parsed.$('.digest-post-embed').forEach((el) => {
490
510
  const attrsRaw = attr(el, 'data-attrs');
491
511
 
@@ -784,7 +804,7 @@ const processPost = (post, siteUrl, options) => {
784
804
  url: `${siteUrl}/tag/${typeSlugSlugify}`,
785
805
  data: {
786
806
  slug: typeSlugSlugify,
787
- name: _.startCase(typeSlug)
807
+ name: startCase(typeSlug)
788
808
  }
789
809
  });
790
810
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-substack",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/TryGhost/migrate.git",
@@ -27,11 +27,10 @@
27
27
  "@tryghost/string": "0.3.1",
28
28
  "he": "1.2.0",
29
29
  "html-entities": "2.6.0",
30
- "lodash": "4.18.1",
31
30
  "simple-dom": "1.4.0",
32
31
  "srcset": "5.0.3",
33
- "@tryghost/mg-fs-utils": "0.21.0",
34
- "@tryghost/mg-utils": "0.6.0"
32
+ "@tryghost/mg-fs-utils": "0.23.0",
33
+ "@tryghost/mg-utils": "0.8.0"
35
34
  },
36
35
  "scripts": {
37
36
  "dev": "echo \"Implement me!\"",