@tryghost/mg-chorus 0.11.8-0 → 0.12.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 +101 -27
- package/build/index.d.ts +5 -0
- package/build/index.js +4 -0
- package/build/index.js.map +1 -0
- package/build/lib/ingest.d.ts +16 -0
- package/build/lib/ingest.js +81 -0
- package/build/lib/ingest.js.map +1 -0
- package/build/lib/json-to-html.d.ts +20 -0
- package/build/lib/json-to-html.js +74 -0
- package/build/lib/json-to-html.js.map +1 -0
- package/build/lib/map.d.ts +20 -0
- package/build/lib/map.js +178 -0
- package/build/lib/map.js.map +1 -0
- package/build/lib/types.d.ts +40 -0
- package/build/lib/types.js +3 -0
- package/build/lib/types.js.map +1 -0
- package/build/test/helpers.d.ts +27 -0
- package/build/test/helpers.js +75 -0
- package/build/test/helpers.js.map +1 -0
- package/build/test/ingest.test.d.ts +1 -0
- package/build/test/ingest.test.js +136 -0
- package/build/test/ingest.test.js.map +1 -0
- package/build/test/json-to-html.test.d.ts +1 -0
- package/build/test/json-to-html.test.js +109 -0
- package/build/test/json-to-html.test.js.map +1 -0
- package/build/test/map.test.d.ts +1 -0
- package/build/test/map.test.js +284 -0
- package/build/test/map.test.js.map +1 -0
- package/package.json +24 -10
- package/index.js +0 -10
- package/lib/json-to-html.js +0 -187
- package/lib/processor.js +0 -146
- package/lib/read-zip.js +0 -87
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Migrate Chorus
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Migrate content from Chorus using its entry exports, and generate a `zip` file you can import into a Ghost installation.
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## Install
|
|
@@ -22,51 +22,125 @@ or
|
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
To run a Ghost API migration, the required command is:
|
|
25
|
+
To run a Chorus migration, the required command is:
|
|
27
26
|
|
|
28
27
|
```sh
|
|
29
|
-
migrate chorus --entries /path/to/file.zip --url
|
|
28
|
+
migrate chorus --entries /path/to/file.zip --url https://example.com
|
|
30
29
|
```
|
|
31
30
|
|
|
32
31
|
It's possible to pass more options, in order to achieve a better migration file for Ghost:
|
|
33
32
|
|
|
34
|
-
- **`--entries`**
|
|
33
|
+
- **`--entries`** (required)
|
|
34
|
+
- Path(s) to Chorus export zips, or directories of `Entry:<id>.json` files
|
|
35
35
|
- array - default: `null`
|
|
36
|
-
|
|
37
|
-
-
|
|
36
|
+
- **`--url`** (required)
|
|
37
|
+
- URL to the live site. It scopes the stable Ghost IDs
|
|
38
38
|
- string - default: `null`
|
|
39
|
-
|
|
40
|
-
- **`--verbose`**
|
|
41
|
-
- bool - default: `false`
|
|
42
|
-
- Show verbose output
|
|
43
|
-
- **`--zip`**
|
|
44
|
-
- bool - default: `true`
|
|
45
|
-
- Create a zip file
|
|
46
|
-
- **`--scrape`**
|
|
39
|
+
- **`--scrape`**
|
|
47
40
|
- Configure scraping tasks
|
|
48
|
-
-
|
|
41
|
+
- array - default: `all`
|
|
49
42
|
- Choices: `all`, `web`, `none`
|
|
50
|
-
- `all`: Scrape
|
|
51
|
-
- `web`: Only scrape metadata from web pages
|
|
43
|
+
- `all`, `web`: Scrape each post's description and Open Graph and Twitter titles and descriptions from its page on the live site
|
|
52
44
|
- `none`: Skip all scraping tasks
|
|
45
|
+
- **`--wait_after_scrape`**
|
|
46
|
+
- Time in ms to wait after a URL is scraped
|
|
47
|
+
- number - default: `200`
|
|
53
48
|
- **`--addPrimaryTag`**
|
|
54
|
-
- string - default: `null`
|
|
55
49
|
- Provide a tag name which should be added to every post as primary tag
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
50
|
+
- string - default: `null`
|
|
51
|
+
- **`--rereadSource`**
|
|
52
|
+
- Read the exports again, replacing the stored source
|
|
53
|
+
- bool - default: `false`
|
|
54
|
+
- **`--postsPerFile`**
|
|
55
|
+
- Maximum posts written per Ghost import JSON file
|
|
56
|
+
- number - default: `2000`
|
|
57
|
+
- **`--cache`**
|
|
60
58
|
- Persist local cache after migration is complete (Only if `--zip` is `true`)
|
|
61
59
|
- bool - default: `true`
|
|
60
|
+
- **`--tmpPath`**
|
|
61
|
+
- Specify the full path where the temporary files will be stored (Defaults a hidden tmp dir)
|
|
62
|
+
- string - default: `null`
|
|
63
|
+
- **`--outputPath`**
|
|
64
|
+
- Specify the full path where the final zip file will be saved to (Defaults to CWD)
|
|
65
|
+
- string - default: `null`
|
|
66
|
+
- **`--cacheName`**
|
|
67
|
+
- Provide a unique name for the cache directory
|
|
68
|
+
- string - default: one based on the exports' full paths
|
|
69
|
+
- **`-V` `--verbose`**
|
|
70
|
+
- Show verbose output
|
|
71
|
+
- bool - default: `false`
|
|
72
|
+
- **`--zip`**
|
|
73
|
+
- Create a zip file
|
|
74
|
+
- bool - default: `true`
|
|
75
|
+
- **`--report`**
|
|
76
|
+
- Write a `.report.json` migration report beside the import, or a `.failed-report.json` if the run fails
|
|
77
|
+
- bool - default: `false`
|
|
78
|
+
- **`--ghostApiUrl`**, **`--ghostAdminKey`**
|
|
79
|
+
- Match authors to existing Ghost users by their placeholder email
|
|
80
|
+
- string - default: `null`
|
|
62
81
|
|
|
63
82
|
A more complex migration command could look like this:
|
|
64
83
|
|
|
65
84
|
```sh
|
|
66
|
-
migrate chorus --entries /path/to/file.zip
|
|
85
|
+
migrate chorus --entries /path/to/file.zip /path/to/other.zip --url https://example.com --addPrimaryTag News
|
|
67
86
|
```
|
|
68
87
|
|
|
69
|
-
This will get all
|
|
88
|
+
This will get all entries from both exports, and apply the tag `News` to every post.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
## Output
|
|
92
|
+
|
|
93
|
+
The import contains HTML; Ghost's importer converts it. `--fallBackHTMLCard` has been removed. A small migration writes `ghost-import.json`, and larger ones write `ghost-import-1.json`, `ghost-import-2.json` and so on, `--postsPerFile` posts each.
|
|
94
|
+
|
|
95
|
+
Each entry becomes a published, public post with the entry's title (`(Untitled)` when it has none), its subtitle (`dek`) as the excerpt, and its `createdAt` as the created and published dates and `updatedAt` as the updated date (a timestamp without a timezone is read as UTC; an invalid `updatedAt` falls back to `createdAt`). Its slug is the last segment of its Chorus URL, such as `my-article` for `https://example.com/2019/9/26/12345678/my-article`, or the title's slug when the URL has no path. Its HTML is built from the entry's body: paragraphs, headings (without bold), lists, block quotes, pull quotes, rules and related links become HTML, and embeds, raw HTML, polls and tables become HTML cards. Images, galleries, sidebars and unknown blocks are left out. Links to other entries in the migration point at their new paths.
|
|
96
|
+
|
|
97
|
+
A post's authors are the entry's byline author, author profile and contributors, in that order, each with a `<slug>@example.com` placeholder email and the Contributor role. Its tags are `--addPrimaryTag` (when given), the entry's community groups, and `#chorus`; internal `#` tags come last. Authors and tags are identified by name, so the same name is one user or tag across posts, and names whose slugs collide get distinct slugs (`jane-doe`, `jane-doe-2`).
|
|
98
|
+
|
|
99
|
+
With `--report`, a `.report.json` beside the ZIP (or in the workspace when `--zip false`) lists imported and skipped counts with diagnostics. Entries without an HTTP or HTTPS URL or a valid `createdAt` are skipped and reported, and a page that cannot be scraped is reported as a warning. When every entry is invalid, or the run fails, `--report` writes a `.failed-report.json` instead.
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
## Source storage
|
|
103
|
+
|
|
104
|
+
The first run stores the exports in an `mg-context` SQLite database in the workspace; later runs map the stored entries again without reading the exports, even if they have moved. Use `--rereadSource` to read them again. Without `--cacheName`, the workspace is keyed by every export's full path, so different exports never share stored data.
|
|
105
|
+
|
|
106
|
+
Each `--entries` path is an export zip, read one entry at a time, or a directory. Every `Entry:<id>.json` file in it, at any depth, is stored as an `entry` record keyed by the entry's `uid` (or the file name, for an entry without one); `entries.csv` and other files are not read. An entry that appears more than once, such as in two overlapping exports, keeps the copy with the latest `updatedAt` (the first on a tie) and reports a `source:conflict`. An export without entries, or with an entry file that is not a JSON object, is rejected and keeps any stored data.
|
|
107
|
+
|
|
108
|
+
Every option applies when the stored records are mapped, so changing `--addPrimaryTag` or `--url` needs no new read. Ghost IDs derive from `--url` and the entry `uid`, tag name or author name, so they stay the same across runs.
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
## Programmatic API
|
|
112
|
+
|
|
113
|
+
The package exports `parse`, `ingest` and `map` for use with `@tryghost/mg-context`. The caller owns the context, export and closure:
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
import {MigrateContext} from '@tryghost/mg-context';
|
|
117
|
+
import {ingest, map} from '@tryghost/mg-chorus';
|
|
118
|
+
|
|
119
|
+
const context = new MigrateContext({dbPath: './migration.sqlite'});
|
|
120
|
+
const rereadSource = process.argv.includes('--rereadSource');
|
|
121
|
+
await context.init();
|
|
122
|
+
try {
|
|
123
|
+
if (!context.sources.hasCompletedIngestion || rereadSource) {
|
|
124
|
+
await ingest(['/path/to/file.zip'], context, {replace: rereadSource});
|
|
125
|
+
}
|
|
126
|
+
const summary = await map({url: 'https://example.com', addPrimaryTag: 'News'}, context);
|
|
127
|
+
for await (const file of context.writeGhostJsonStream('./output', {filename: 'ghost-import'})) {
|
|
128
|
+
// Consume one file descriptor at a time.
|
|
129
|
+
}
|
|
130
|
+
await context.writeMigrationReport('./migration.report.json', summary);
|
|
131
|
+
} finally {
|
|
132
|
+
await context.close();
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
- `ingest(entries, context, {replace})` reads one export path, or an array of them, into `context.sources` inside `context.sources.ingest()`. Explicit `replace: true` is required when completed source data exists; a failed read keeps the previous data.
|
|
137
|
+
- `parse(entries)` yields the same records as `SourceRecordInput` values, one at a time, without storing them.
|
|
138
|
+
- `map({url, addPrimaryTag}, context, {ghostUsers?})` rebuilds mapped content and returns `{selected, imported, skipped}`. `url` is required. `ghostUsers` may be an iterable or async iterable of existing Ghost users; when one has an author's placeholder email, posts keep that user's Ghost ID, slug and roles, and Ghost users' slugs are reserved for them.
|
|
139
|
+
- `jsonToHtml(components)` converts an entry's body components to HTML, and the `EntryBody*` functions convert one block each. `entryUrl(entry)` gives an entry's HTTP or HTTPS URL or `null`, and `ghostId(site, kind, key)` the stable Ghost ID `map()` uses.
|
|
140
|
+
|
|
141
|
+
The previous default export (`(entries, options)`, which read every entry into memory and returned `{posts}` for `toGhostJSON`) and its `processor` have been removed.
|
|
142
|
+
|
|
143
|
+
The CLI's programmatic `outputStorage.upload({body, fileName, size})` receives a Node readable stream as `body`, for the ZIP and, with `--report`, the report, and must consume it before resolving to the remote path. The uploaded ZIP is named like the local one, such as `gh-chorus-file-1700000000000.zip` for `file.zip`.
|
|
70
144
|
|
|
71
145
|
|
|
72
146
|
## Develop
|
|
@@ -83,13 +157,13 @@ Follow the instructions for the top-level repo.
|
|
|
83
157
|
To run a local development copy, `cd` into this directory, and use `pnpm dev` instead of `migrate` like so:
|
|
84
158
|
|
|
85
159
|
```sh
|
|
86
|
-
pnpm dev chorus
|
|
160
|
+
pnpm dev chorus --entries /path/to/file.zip --url https://example.com
|
|
87
161
|
```
|
|
88
162
|
|
|
89
163
|
|
|
90
164
|
## Test
|
|
91
165
|
|
|
92
|
-
- `pnpm test`
|
|
166
|
+
- `pnpm test:local` builds the package and runs its tests with 100% coverage
|
|
93
167
|
- Linting and formatting are run from the repo root (`pnpm lint`, `pnpm format`)
|
|
94
168
|
|
|
95
169
|
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ingest, parse } from './lib/ingest.js';
|
|
2
|
+
export { entryUrl, ghostId, map } from './lib/map.js';
|
|
3
|
+
export { default as jsonToHtml, EntryBodyList, EntryBodyParagraph, EntryBodyEmbed, EntryBodyHeading, EntryBodyHTML, EntryBodyPoll, EntryBodyPullquote, EntryBodyTable, EntryBodyBlockquote, EntryBodyHorizontalRule, EntryBodyRelatedList } from './lib/json-to-html.js';
|
|
4
|
+
export type { MappingServices, MappingSummary } from './lib/map.js';
|
|
5
|
+
export type { ChorusComponent, ChorusEntry, ChorusOptions } from './lib/types.js';
|
package/build/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ingest, parse } from './lib/ingest.js';
|
|
2
|
+
export { entryUrl, ghostId, map } from './lib/map.js';
|
|
3
|
+
export { default as jsonToHtml, EntryBodyList, EntryBodyParagraph, EntryBodyEmbed, EntryBodyHeading, EntryBodyHTML, EntryBodyPoll, EntryBodyPullquote, EntryBodyTable, EntryBodyBlockquote, EntryBodyHorizontalRule, EntryBodyRelatedList } from './lib/json-to-html.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,cAAc,CAAC;AACpD,OAAO,EACH,OAAO,IAAI,UAAU,EACrB,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACvB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MigrateContext, SourceRecordInput } from '@tryghost/mg-context';
|
|
2
|
+
/**
|
|
3
|
+
* Yield the originals of one or more Chorus exports one at a time without storing them: each `Entry:<id>.json`
|
|
4
|
+
* file as an `entry` record keyed by the entry's `uid`. Each input is an export zip or a directory of entry files,
|
|
5
|
+
* read in the order given. Rejects an input without entries, or an entry file that is not a JSON object.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parse(entries: string | string[]): AsyncGenerator<SourceRecordInput>;
|
|
8
|
+
/**
|
|
9
|
+
* Read one or more Chorus export zips or directories into `context.sources`. An entry that appears more than once
|
|
10
|
+
* keeps the version with the latest `updatedAt` (the first on a tie) and reports a `source:conflict` when the
|
|
11
|
+
* versions differ. Explicit `replace: true` is required when completed source data exists; a failed read keeps the
|
|
12
|
+
* previous data.
|
|
13
|
+
*/
|
|
14
|
+
export declare function ingest(entries: string | string[], context: MigrateContext, { replace }?: {
|
|
15
|
+
replace?: boolean;
|
|
16
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
2
|
+
import { basename, resolve } from 'node:path';
|
|
3
|
+
import fsUtils from '@tryghost/mg-fs-utils';
|
|
4
|
+
/** A Chorus export holds each entry as `Entry:<id>.json`, beside files the migration does not use. */
|
|
5
|
+
const ENTRY = /(?:^|\/)(Entry:[^/]+)\.json$/;
|
|
6
|
+
const isEntry = (entry) => !entry.isDirectory && ENTRY.test(entry.path);
|
|
7
|
+
/** The entry files of one export zip or directory, one at a time, in archive or path order. */
|
|
8
|
+
async function* entryFiles(input) {
|
|
9
|
+
if ((await stat(input)).isDirectory()) {
|
|
10
|
+
for (const file of await fsUtils.listInputFiles(input, '**/Entry:*.json')) {
|
|
11
|
+
yield { path: file.name, read: () => readFile(file.path) };
|
|
12
|
+
}
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
for await (const entry of fsUtils.zip.entries(input, { filter: isEntry })) {
|
|
16
|
+
yield { path: entry.path, read: () => entry.read() };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function entryRecord(source, file) {
|
|
20
|
+
let entry;
|
|
21
|
+
try {
|
|
22
|
+
entry = JSON.parse((await file.read()).toString('utf8'));
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw new Error(`${source}: ${file.path} is not valid JSON (${error.message})`, { cause: error });
|
|
26
|
+
}
|
|
27
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
28
|
+
throw new Error(`${source}: ${file.path} is not a Chorus entry`);
|
|
29
|
+
}
|
|
30
|
+
const { uid } = entry;
|
|
31
|
+
return {
|
|
32
|
+
kind: 'entry',
|
|
33
|
+
// Chorus names each file after the entry's `uid`; the file name is the fallback for an entry without one.
|
|
34
|
+
key: typeof uid === 'string' && uid.trim() ? uid.trim() : file.path.match(ENTRY)[1],
|
|
35
|
+
content: JSON.stringify(entry),
|
|
36
|
+
format: 'json',
|
|
37
|
+
metadata: { file: source, path: file.path }
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Yield the originals of one or more Chorus exports one at a time without storing them: each `Entry:<id>.json`
|
|
42
|
+
* file as an `entry` record keyed by the entry's `uid`. Each input is an export zip or a directory of entry files,
|
|
43
|
+
* read in the order given. Rejects an input without entries, or an entry file that is not a JSON object.
|
|
44
|
+
*/
|
|
45
|
+
export async function* parse(entries) {
|
|
46
|
+
for (const input of [entries].flat()) {
|
|
47
|
+
const source = basename(resolve(input));
|
|
48
|
+
let found = false;
|
|
49
|
+
for await (const file of entryFiles(input)) {
|
|
50
|
+
found = true;
|
|
51
|
+
yield await entryRecord(source, file);
|
|
52
|
+
}
|
|
53
|
+
if (!found) {
|
|
54
|
+
throw new Error(`${input}: No Chorus entries found (expected Entry:<id>.json files)`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const updated = (content) => Date.parse(JSON.parse(content).updatedAt);
|
|
59
|
+
/** The later version of an entry wins; a tie, or a missing or invalid `updatedAt`, keeps the earlier one. */
|
|
60
|
+
function newer(existing, incoming) {
|
|
61
|
+
return updated(incoming.content) > updated(existing.content) ? 'replace' : 'keep';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Read one or more Chorus export zips or directories into `context.sources`. An entry that appears more than once
|
|
65
|
+
* keeps the version with the latest `updatedAt` (the first on a tie) and reports a `source:conflict` when the
|
|
66
|
+
* versions differ. Explicit `replace: true` is required when completed source data exists; a failed read keeps the
|
|
67
|
+
* previous data.
|
|
68
|
+
*/
|
|
69
|
+
export async function ingest(entries, context, { replace = false } = {}) {
|
|
70
|
+
const inputs = [entries].flat();
|
|
71
|
+
if (!inputs.length) {
|
|
72
|
+
throw new Error('Chorus ingestion needs at least one export zip or directory.');
|
|
73
|
+
}
|
|
74
|
+
const files = inputs.map(input => basename(resolve(input)));
|
|
75
|
+
await context.sources.ingest({ replace, metadata: { adapter: 'chorus', files } }, async (stage) => {
|
|
76
|
+
for await (const record of parse(inputs)) {
|
|
77
|
+
stage.reconcile(record, { choose: newer });
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=ingest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingest.js","sourceRoot":"","sources":["../../src/lib/ingest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AAC5C,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAG5C,sGAAsG;AACtG,MAAM,KAAK,GAAG,8BAA8B,CAAC;AAC7C,MAAM,OAAO,GAAG,CAAC,KAA2C,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAQ9G,+FAA+F;AAC/F,KAAK,SAAS,CAAC,CAAC,UAAU,CAAC,KAAa;IACpC,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;QACpC,KAAK,MAAM,IAAI,IAAI,MAAM,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,iBAAiB,CAAC,EAAE,CAAC;YACxE,MAAM,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAC,CAAC;QAC7D,CAAC;QACD,OAAO;IACX,CA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AM,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,EAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAC,EAAC,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;QACxF,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACvC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC;QAC7C,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ChorusComponent } from './types.js';
|
|
2
|
+
type Block = ChorusComponent;
|
|
3
|
+
declare const EntryBodyList: (block: Block) => string;
|
|
4
|
+
declare const EntryBodyParagraph: (block: Block) => string;
|
|
5
|
+
declare const EntryBodyEmbed: (block: Block) => string;
|
|
6
|
+
declare const EntryBodyHeading: (block: Block) => string;
|
|
7
|
+
declare const EntryBodyHTML: (block: Block) => string;
|
|
8
|
+
declare const EntryBodyPoll: (block: Block) => string;
|
|
9
|
+
declare const EntryBodyPullquote: (block: Block) => string;
|
|
10
|
+
declare const EntryBodyTable: (block: Block) => string;
|
|
11
|
+
declare const EntryBodyBlockquote: (block: Block) => string;
|
|
12
|
+
declare const EntryBodyHorizontalRule: () => string;
|
|
13
|
+
declare const EntryBodyRelatedList: (block: Block) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Convert a Chorus entry's body components to HTML. Images, galleries, sidebars and unknown block types are left
|
|
16
|
+
* out.
|
|
17
|
+
*/
|
|
18
|
+
declare const jsonToHtml: (blocks: Block[] | null | undefined) => string;
|
|
19
|
+
export default jsonToHtml;
|
|
20
|
+
export { EntryBodyList, EntryBodyParagraph, EntryBodyEmbed, EntryBodyHeading, EntryBodyHTML, EntryBodyPoll, EntryBodyPullquote, EntryBodyTable, EntryBodyBlockquote, EntryBodyHorizontalRule, EntryBodyRelatedList };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const EntryBodyList = (block) => {
|
|
2
|
+
const tag = block.ordered ? 'ol' : 'ul';
|
|
3
|
+
const items = block.items.map((item) => `<li>${item.line.html}</li>`).join('');
|
|
4
|
+
return `<${tag}>${items}</${tag}>`;
|
|
5
|
+
};
|
|
6
|
+
const EntryBodyParagraph = (block) => `<p>${block.contents.html}</p>`;
|
|
7
|
+
const EntryBodyEmbed = (block) => `<!--kg-card-begin: html-->${block.embed.embedHtml}<!--kg-card-end: html-->`;
|
|
8
|
+
const EntryBodyHeading = (block) => {
|
|
9
|
+
// Remove bold tags from headings, leaving italics alone
|
|
10
|
+
const contents = block.contents.html.replace(/<\/?(?:strong|b)>/g, '');
|
|
11
|
+
return `<h${block.level}>${contents}</h${block.level}>`;
|
|
12
|
+
};
|
|
13
|
+
const EntryBodyHTML = (block) => `<!--kg-card-begin: html-->${block.rawHtml}<!--kg-card-end: html-->`;
|
|
14
|
+
const EntryBodyPoll = (block) => {
|
|
15
|
+
const html = [];
|
|
16
|
+
if (block.poll.title) {
|
|
17
|
+
html.push(`<h3>${block.poll.title}</h3>`);
|
|
18
|
+
}
|
|
19
|
+
html.push('<!--kg-card-begin: html-->', '<table>', '<tbody>');
|
|
20
|
+
for (const row of block.poll.options) {
|
|
21
|
+
html.push(`<tr><td>${row.label}</td><td>${row.votes}</td></tr>`);
|
|
22
|
+
}
|
|
23
|
+
html.push('</tbody>', '</table>', '<!--kg-card-end: html-->');
|
|
24
|
+
return html.join('');
|
|
25
|
+
};
|
|
26
|
+
const EntryBodyPullquote = (block) => `<blockquote class="kg-blockquote-alt">${block.quote.html}</blockquote>`;
|
|
27
|
+
const EntryBodyTable = (block) => {
|
|
28
|
+
const html = [];
|
|
29
|
+
if (block.table.title) {
|
|
30
|
+
html.push(`<h3>${block.table.title}</h3>`);
|
|
31
|
+
}
|
|
32
|
+
html.push('<!--kg-card-begin: html-->', '<table>', '<thead>');
|
|
33
|
+
for (const column of block.table.columns) {
|
|
34
|
+
html.push(`<th>${column}</th>`);
|
|
35
|
+
}
|
|
36
|
+
html.push('</thead>', '<tbody>');
|
|
37
|
+
for (const row of block.table.rows) {
|
|
38
|
+
html.push(`<tr>${row.map((cell) => `<td>${cell}</td>`).join('')}</tr>`);
|
|
39
|
+
}
|
|
40
|
+
html.push('</tbody>', '</table>', '<!--kg-card-end: html-->');
|
|
41
|
+
return html.join('');
|
|
42
|
+
};
|
|
43
|
+
const EntryBodyBlockquote = (block) => {
|
|
44
|
+
const paragraphs = block.paragraphs.map((paragraph) => `<p>${paragraph.contents.html}</p>`).join('');
|
|
45
|
+
return `<blockquote>${paragraphs}</blockquote>`;
|
|
46
|
+
};
|
|
47
|
+
const EntryBodyHorizontalRule = () => '<hr>';
|
|
48
|
+
const EntryBodyRelatedList = (block) => {
|
|
49
|
+
const links = block.items.map((item) => `<a href="${item.url}">${item.title}</a>`).join('<br>');
|
|
50
|
+
return `<hr><h4>Related</h4><p>${links}</p><hr>`;
|
|
51
|
+
};
|
|
52
|
+
const converters = {
|
|
53
|
+
EntryBodyParagraph,
|
|
54
|
+
EntryBodyEmbed,
|
|
55
|
+
EntryBodyList,
|
|
56
|
+
EntryBodyHeading,
|
|
57
|
+
EntryBodyHTML,
|
|
58
|
+
EntryBodyPoll,
|
|
59
|
+
EntryBodyPullquote,
|
|
60
|
+
EntryBodyTable,
|
|
61
|
+
EntryBodyBlockquote,
|
|
62
|
+
EntryBodyHorizontalRule,
|
|
63
|
+
EntryBodyRelatedList
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Convert a Chorus entry's body components to HTML. Images, galleries, sidebars and unknown block types are left
|
|
67
|
+
* out.
|
|
68
|
+
*/
|
|
69
|
+
const jsonToHtml = (blocks) => (blocks ?? [])
|
|
70
|
+
.map(block => (Object.hasOwn(converters, String(block.__typename)) ? converters[block.__typename](block) : ''))
|
|
71
|
+
.join('');
|
|
72
|
+
export default jsonToHtml;
|
|
73
|
+
export { EntryBodyList, EntryBodyParagraph, EntryBodyEmbed, EntryBodyHeading, EntryBodyHTML, EntryBodyPoll, EntryBodyPullquote, EntryBodyTable, EntryBodyBlockquote, EntryBodyHorizontalRule, EntryBodyRelatedList };
|
|
74
|
+
//# sourceMappingURL=json-to-html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-to-html.js","sourceRoot":"","sources":["../../src/lib/json-to-html.ts"],"names":[],"mappings":"AAIA,MAAM,aAAa,GAAG,CAAC,KAAY,EAAU,EAAE;IAC3C,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpF,OAAO,IAAI,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,KAAY,EAAU,EAAE,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC;AAErF,MAAM,cAAc,GAAG,CAAC,KAAY,EAAU,EAAE,CAC5C,6BAA6B,KAAK,CAAC,KAAK,CAAC,SAAS,0BAA0B,CAAC;AAEjF,MAAM,gBAAgB,GAAG,CAAC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EAAE,CAAC,YAAY,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,KAAK,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrG,OAAO,0BAA0B,KAAK,UAAU,CAAC;AACrD,CAAC,CAAC;AAEF,MAAM,UAAU,GAA6C;IACzD,kBAAkB;IAClB,cAAc;IACd,aAAa;IACb,gBAAgB;IAChB,aAAa;IACb,aAAa;IACb,kBAAkB;IAClB,cAAc;IACd,mBAAmB;IACnB,uBAAuB;IACvB,oBAAoB;CACvB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,MAAkC,EAAU,EAAE,CAC9D,CAAC,MAAM,IAAI,EAAE,CAAC;KACT,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,UAAW,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KAC/G,IAAI,CAAC,EAAE,CAAC,CAAC;AAElB,eAAe,UAAU,CAAC;AAE1B,OAAO,EACH,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACvB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MigrateContext } from '@tryghost/mg-context';
|
|
2
|
+
import type { MappingSummary } from '@tryghost/mg-context';
|
|
3
|
+
import type { GhostUser } from '@tryghost/mg-ghost-authors';
|
|
4
|
+
import type { ChorusEntry, ChorusOptions } from './types.js';
|
|
5
|
+
export type { MappingSummary };
|
|
6
|
+
export interface MappingServices {
|
|
7
|
+
/** Existing Ghost users; an author whose placeholder email matches one keeps that user's ID, slug and roles. */
|
|
8
|
+
ghostUsers?: Iterable<GhostUser> | AsyncIterable<GhostUser>;
|
|
9
|
+
}
|
|
10
|
+
/** A stable Ghost ID for an entry `uid`, tag name or author name, scoped to the site. */
|
|
11
|
+
export declare function ghostId(site: string, kind: string, key: string): string;
|
|
12
|
+
/** An entry's URL on the live site, or `null` when it has no HTTP or HTTPS URL. */
|
|
13
|
+
export declare function entryUrl(entry: ChorusEntry): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Rebuild posts, tags and authors from the stored entries. Each entry becomes a published, public post whose slug
|
|
16
|
+
* is the last segment of its Chorus URL, with its byline author, author profile and contributors as authors, and
|
|
17
|
+
* `addPrimaryTag`, its community groups and `#chorus` as tags. `addPrimaryTag` applies here, so changing it needs
|
|
18
|
+
* no new read. Entries without a valid URL or `createdAt` are skipped with a `record:skipped` diagnostic.
|
|
19
|
+
*/
|
|
20
|
+
export declare function map(options: ChorusOptions, context: MigrateContext, services?: MappingServices): Promise<MappingSummary>;
|
package/build/lib/map.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { AuthorContext, MappingState, PostContext, RecordDataError, TagContext, ghostId as coreGhostId } from '@tryghost/mg-context';
|
|
2
|
+
import { mergeUsersWithGhost } from '@tryghost/mg-ghost-authors';
|
|
3
|
+
import { slugify } from '@tryghost/string';
|
|
4
|
+
import { dateUtils, stringUtils, urlUtils } from '@tryghost/mg-utils';
|
|
5
|
+
import jsonToHtml from './json-to-html.js';
|
|
6
|
+
const ROLES = ['Contributor', 'Author', 'Editor', 'Administrator'];
|
|
7
|
+
/** A stable Ghost ID for an entry `uid`, tag name or author name, scoped to the site. */
|
|
8
|
+
export function ghostId(site, kind, key) {
|
|
9
|
+
return coreGhostId('mg-chorus:1', site, kind, key);
|
|
10
|
+
}
|
|
11
|
+
/** The host and path of the live site's URL, which scope stable Ghost IDs to one site. */
|
|
12
|
+
function siteScope(value) {
|
|
13
|
+
const url = urlUtils.httpUrl(value);
|
|
14
|
+
if (!url) {
|
|
15
|
+
throw new Error('Chorus migrations need the site URL (--url) as an HTTP or HTTPS URL.');
|
|
16
|
+
}
|
|
17
|
+
return urlUtils.canonicalSite(url);
|
|
18
|
+
}
|
|
19
|
+
/** An entry's URL on the live site, or `null` when it has no HTTP or HTTPS URL. */
|
|
20
|
+
export function entryUrl(entry) {
|
|
21
|
+
return urlUtils.httpUrl(entry.url)?.href ?? null;
|
|
22
|
+
}
|
|
23
|
+
/** The decoded last segment of a URL's path, as a slug: `my-article` for `https://example.com/2019/9/26/1/my-article`. */
|
|
24
|
+
function urlSlug(url) {
|
|
25
|
+
const segment = new URL(url).pathname.split('/').filter(Boolean).pop() ?? '';
|
|
26
|
+
try {
|
|
27
|
+
return slugify(decodeURIComponent(segment));
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return slugify(segment);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** A trimmed name, or `undefined` when it is not a string or is blank. */
|
|
34
|
+
function name(value) {
|
|
35
|
+
return (typeof value === 'string' && value.trim()) || undefined;
|
|
36
|
+
}
|
|
37
|
+
const placeholderEmail = (slug) => `${slug.slice(0, 50).replace(/-+$/, '')}@example.com`;
|
|
38
|
+
/**
|
|
39
|
+
* The saved author for a name. Authors are identified by name, so names whose slugs collide stay separate users
|
|
40
|
+
* with distinct slugs and emails. A Ghost user with the author's `<slug>@example.com` email supplies its ID, slug
|
|
41
|
+
* and roles.
|
|
42
|
+
*/
|
|
43
|
+
function authorEntity(state, site, authorName) {
|
|
44
|
+
const context = state.context;
|
|
45
|
+
const binding = state.getBinding('author', authorName);
|
|
46
|
+
if (binding) {
|
|
47
|
+
return AuthorContext.fromRow(context.db.stmts.findAuthorById.get(binding));
|
|
48
|
+
}
|
|
49
|
+
const base = slugify(authorName) || 'author';
|
|
50
|
+
let data = {
|
|
51
|
+
name: authorName,
|
|
52
|
+
slug: base,
|
|
53
|
+
email: placeholderEmail(base),
|
|
54
|
+
roles: ['Contributor']
|
|
55
|
+
};
|
|
56
|
+
const match = state.get('ghost-user', data.email);
|
|
57
|
+
if (match) {
|
|
58
|
+
// Names that share a placeholder email are the same Ghost user.
|
|
59
|
+
const same = state.getBinding('ghost-author', match.id);
|
|
60
|
+
if (same) {
|
|
61
|
+
state.bind('author', authorName, same);
|
|
62
|
+
return AuthorContext.fromRow(context.db.stmts.findAuthorById.get(same));
|
|
63
|
+
}
|
|
64
|
+
data = { ...mergeUsersWithGhost([{ url: '', data: data }], [match])[0].data };
|
|
65
|
+
}
|
|
66
|
+
const id = data.id || ghostId(site, 'author', authorName);
|
|
67
|
+
delete data.id;
|
|
68
|
+
if (data.roles.some((role) => !ROLES.includes(role))) {
|
|
69
|
+
context.recordDiagnostic('operation:warning', {
|
|
70
|
+
author: authorName,
|
|
71
|
+
reason: 'Unsupported author roles replaced by supported Ghost roles'
|
|
72
|
+
});
|
|
73
|
+
data.roles = data.roles.filter((role) => ROLES.includes(role));
|
|
74
|
+
if (!data.roles.length) {
|
|
75
|
+
data.roles = ['Contributor'];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
data.slug = state.uniqueSlug('author', data.slug, id);
|
|
79
|
+
if (!match && data.slug !== base) {
|
|
80
|
+
// Distinct authors need distinct emails as well as slugs.
|
|
81
|
+
data.email = placeholderEmail(data.slug);
|
|
82
|
+
}
|
|
83
|
+
const author = new AuthorContext();
|
|
84
|
+
for (const [field, value] of Object.entries(data)) {
|
|
85
|
+
if (value !== undefined) {
|
|
86
|
+
author.set(field, value);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
author.ghostId = id;
|
|
90
|
+
author.save(context.db);
|
|
91
|
+
state.bind('author', authorName, author.dbId);
|
|
92
|
+
state.bind('ghost-author', id, author.dbId);
|
|
93
|
+
return author;
|
|
94
|
+
}
|
|
95
|
+
/** The saved tag for a name. Names whose slugs collide get distinct slugs; `#` names are internal `hash-` tags. */
|
|
96
|
+
function tagEntity(state, site, tagName) {
|
|
97
|
+
const context = state.context;
|
|
98
|
+
const binding = state.getBinding('tag', tagName);
|
|
99
|
+
if (binding) {
|
|
100
|
+
return TagContext.fromRow(context.db.stmts.findTagById.get(binding));
|
|
101
|
+
}
|
|
102
|
+
const slug = tagName.startsWith('#') ? `hash-${slugify(tagName)}` : slugify(tagName);
|
|
103
|
+
const tag = new TagContext({ name: tagName, slug: state.uniqueSlug('tag', slug) });
|
|
104
|
+
tag.ghostId = ghostId(site, 'tag', tagName);
|
|
105
|
+
tag.save(context.db);
|
|
106
|
+
state.bind('tag', tagName, tag.dbId);
|
|
107
|
+
return tag;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Rebuild posts, tags and authors from the stored entries. Each entry becomes a published, public post whose slug
|
|
111
|
+
* is the last segment of its Chorus URL, with its byline author, author profile and contributors as authors, and
|
|
112
|
+
* `addPrimaryTag`, its community groups and `#chorus` as tags. `addPrimaryTag` applies here, so changing it needs
|
|
113
|
+
* no new read. Entries without a valid URL or `createdAt` are skipped with a `record:skipped` diagnostic.
|
|
114
|
+
*/
|
|
115
|
+
export async function map(options, context, services = {}) {
|
|
116
|
+
if (!context.sources.hasCompletedIngestion) {
|
|
117
|
+
throw new Error('Ingest a complete Chorus export before mapping.');
|
|
118
|
+
}
|
|
119
|
+
const site = siteScope(options.url);
|
|
120
|
+
const primaryTag = name(options.addPrimaryTag);
|
|
121
|
+
const state = new MappingState(context, 'mg-chorus');
|
|
122
|
+
return context.rebuildMappedContent(async () => {
|
|
123
|
+
for await (const user of services.ghostUsers ?? []) {
|
|
124
|
+
state.reserveSlug('author', user.slug, user.id);
|
|
125
|
+
if (user.email) {
|
|
126
|
+
state.set('ghost-user', user.email.toLowerCase(), user);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return context.mapRecords(context.sources.records({ kind: 'entry' }), async (record) => {
|
|
130
|
+
const entry = JSON.parse(record.content);
|
|
131
|
+
const url = entryUrl(entry);
|
|
132
|
+
if (!url) {
|
|
133
|
+
throw new RecordDataError('Entry has no valid URL');
|
|
134
|
+
}
|
|
135
|
+
const created = dateUtils.parseDate(entry.createdAt);
|
|
136
|
+
if (!created) {
|
|
137
|
+
throw new RecordDataError('Invalid Chorus createdAt');
|
|
138
|
+
}
|
|
139
|
+
const title = name(entry.title) ?? '(Untitled)';
|
|
140
|
+
const post = new PostContext({ lookupKey: record.key });
|
|
141
|
+
post.ghostId = ghostId(site, 'post', record.key);
|
|
142
|
+
post.set('title', title);
|
|
143
|
+
post.set('slug', urlSlug(url) || slugify(title));
|
|
144
|
+
post.set('custom_excerpt', name(entry.dek?.html) ?? null);
|
|
145
|
+
post.set('status', 'published');
|
|
146
|
+
post.set('visibility', 'public');
|
|
147
|
+
post.set('type', 'post');
|
|
148
|
+
post.set('created_at', created);
|
|
149
|
+
post.set('published_at', created);
|
|
150
|
+
post.set('updated_at', dateUtils.parseDate(entry.updatedAt) ?? created);
|
|
151
|
+
post.set('html', jsonToHtml(entry.body?.components));
|
|
152
|
+
const authorNames = [
|
|
153
|
+
name(entry.author?.fullOrUserName),
|
|
154
|
+
name(entry.authorProfile?.name),
|
|
155
|
+
...(entry.contributors ?? []).map(contributor => name(contributor?.fullOrUserName))
|
|
156
|
+
].filter((value) => Boolean(value));
|
|
157
|
+
for (const author of authorNames.map(authorName => authorEntity(state, site, authorName))) {
|
|
158
|
+
post.addAuthor(author);
|
|
159
|
+
context.sources.link(record.id, { type: 'author', id: author.dbId });
|
|
160
|
+
}
|
|
161
|
+
const tagNames = [
|
|
162
|
+
primaryTag,
|
|
163
|
+
...(entry.communityGroups ?? []).map(group => name(group?.name)),
|
|
164
|
+
'#chorus'
|
|
165
|
+
].filter((value) => Boolean(value));
|
|
166
|
+
// Public tags come first, then internal (`#`) tags, keeping their order otherwise.
|
|
167
|
+
tagNames.sort((a, b) => Number(a.startsWith('#')) - Number(b.startsWith('#')));
|
|
168
|
+
for (const tag of tagNames.map(tagName => tagEntity(state, site, tagName))) {
|
|
169
|
+
post.addTag(tag);
|
|
170
|
+
context.sources.link(record.id, { type: 'tag', id: tag.dbId });
|
|
171
|
+
}
|
|
172
|
+
post.save(context.db);
|
|
173
|
+
context.sources.link(record.id, { type: 'post', id: post.dbId });
|
|
174
|
+
context.addLink(stringUtils.cleanURL(url), `/${post.get('slug')}/`);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../../src/lib/map.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EACb,YAAY,EAEZ,WAAW,EACX,eAAe,EACf,UAAU,EACV,OAAO,IAAI,WAAW,EACzB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAC,OAAO,EAAC,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AACpE,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAU3C,MAAM,KAAK,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;AAEnE,yFAAyF;AACzF,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,IAAY,EAAE,GAAW;IAC3D,OAAO,WAAW,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;AACvD,CAAC;AAED,0FAA0F;AAC1F,SAAS,SAAS,CAAC,KAAc;IAC7B,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpC,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,QAAQ,CAAC,K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