@tryghost/mg-substack 0.3.5 → 0.3.7

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.
Files changed (3) hide show
  1. package/README.md +3 -0
  2. package/lib/mapper.js +31 -15
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -58,6 +58,9 @@ It's possible to pass more options, in order to achieve a better migration file
58
58
  - **`-e` `--email`**
59
59
  - Provide an email domain for users e.g. `person@example.com` (Is ignored if `--useMetaAuthor` is provided)
60
60
  - bool/string - default: `false`
61
+ - **`--addTag`**
62
+ - string - default: `null`
63
+ - 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'`)
61
64
  - **`--drafts`**
62
65
  - Import draft posts
63
66
  - bool - default: `true`
package/lib/mapper.js CHANGED
@@ -6,7 +6,7 @@ import {_base as debugFactory} from '@tryghost/debug';
6
6
 
7
7
  const debug = debugFactory('migrate:substack:mapper');
8
8
 
9
- const mapConfig = (data, {url, email, useMetaAuthor}) => {
9
+ const mapConfig = (data, {url, email, useMetaAuthor, addTag}) => {
10
10
  const slug = data.post_id.replace(/^(?:\d{1,10}\.)(\S*)/gm, '$1');
11
11
 
12
12
  // Get an ISO 8601 date - https://date-fns.org/docs/formatISO
@@ -30,23 +30,39 @@ const mapConfig = (data, {url, email, useMetaAuthor}) => {
30
30
  html: data.html || null,
31
31
  status: data.is_published.toLowerCase() === `true` ? 'published' : 'draft',
32
32
  visibility: data.audience === 'only_paid' ? 'paid' : data.audience === 'only_free' ? 'members' : 'public',
33
- tags: [
34
- {
35
- url: 'migrator-added-tag',
36
- data: {
37
- name: '#substack'
38
- }
39
- },
40
- {
41
- url: `${url}/tag/${typeSlug}`,
42
- data: {
43
- name: _.startCase(typeSlug)
44
- }
45
- }
46
- ]
33
+ tags: []
47
34
  }
48
35
  };
49
36
 
37
+ let typeSlugSlugify = slugify(typeSlug);
38
+ mappedData.data.tags.push({
39
+ url: `${url}/tag/${typeSlugSlugify}`,
40
+ data: {
41
+ slug: typeSlugSlugify,
42
+ name: _.startCase(typeSlug)
43
+ }
44
+ });
45
+
46
+ if (addTag) {
47
+ let trimmedTag = addTag.trim();
48
+ let trimmedTagSlug = slugify(trimmedTag);
49
+ mappedData.data.tags.push({
50
+ url: `${url}/tag/${trimmedTagSlug}`,
51
+ data: {
52
+ slug: trimmedTagSlug,
53
+ name: trimmedTag
54
+ }
55
+ });
56
+ }
57
+
58
+ mappedData.data.tags.push({
59
+ url: `migrator-added-tag`,
60
+ data: {
61
+ slug: `hash-substack`,
62
+ name: `#substack`
63
+ }
64
+ });
65
+
50
66
  // Add an internal tag based on the type of post
51
67
  mappedData.data.tags.push({
52
68
  url: `migrator-added-tag-substack-type-${typeSlug}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-substack",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-substack",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -28,12 +28,12 @@
28
28
  "@tryghost/debug": "0.1.21",
29
29
  "@tryghost/errors": "1.2.20",
30
30
  "@tryghost/kg-default-cards": "6.0.4",
31
- "@tryghost/mg-fs-utils": "^0.12.4",
31
+ "@tryghost/mg-fs-utils": "^0.12.5",
32
32
  "@tryghost/string": "0.2.2",
33
33
  "date-fns": "2.29.3",
34
34
  "html-entities": "2.3.3",
35
35
  "lodash": "4.17.21",
36
36
  "simple-dom": "1.4.0"
37
37
  },
38
- "gitHead": "9a613a18b22c794c0e3eed734c4b6963e905f68d"
38
+ "gitHead": "52a63bfa94530ec88efba202ad9581bcd4a9790c"
39
39
  }