@tryghost/mg-tinynews 0.10.8-0 → 0.11.0-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.
Files changed (42) hide show
  1. package/README.md +112 -30
  2. package/build/index.d.ts +8 -0
  3. package/build/index.js +5 -0
  4. package/build/index.js.map +1 -0
  5. package/build/lib/ingest.d.ts +18 -0
  6. package/build/lib/ingest.js +91 -0
  7. package/build/lib/ingest.js.map +1 -0
  8. package/build/lib/json-to-html.d.ts +35 -0
  9. package/build/lib/json-to-html.js +238 -0
  10. package/build/lib/json-to-html.js.map +1 -0
  11. package/build/lib/map.d.ts +26 -0
  12. package/build/lib/map.js +209 -0
  13. package/build/lib/map.js.map +1 -0
  14. package/build/lib/process.d.ts +76 -0
  15. package/build/lib/process.js +235 -0
  16. package/build/lib/process.js.map +1 -0
  17. package/build/lib/text.d.ts +6 -0
  18. package/build/lib/text.js +60 -0
  19. package/build/lib/text.js.map +1 -0
  20. package/build/lib/types.d.ts +112 -0
  21. package/build/lib/types.js +3 -0
  22. package/build/lib/types.js.map +1 -0
  23. package/build/test/helpers.d.ts +25 -0
  24. package/build/test/helpers.js +74 -0
  25. package/build/test/helpers.js.map +1 -0
  26. package/build/test/ingest.test.d.ts +1 -0
  27. package/build/test/ingest.test.js +134 -0
  28. package/build/test/ingest.test.js.map +1 -0
  29. package/build/test/json-to-html.test.d.ts +1 -0
  30. package/build/test/json-to-html.test.js +662 -0
  31. package/build/test/json-to-html.test.js.map +1 -0
  32. package/build/test/map.test.d.ts +1 -0
  33. package/build/test/map.test.js +367 -0
  34. package/build/test/map.test.js.map +1 -0
  35. package/build/test/process.test.d.ts +1 -0
  36. package/build/test/process.test.js +261 -0
  37. package/build/test/process.test.js.map +1 -0
  38. package/package.json +24 -10
  39. package/index.js +0 -7
  40. package/lib/json-to-html.js +0 -324
  41. package/lib/mapper.js +0 -368
  42. package/lib/text.js +0 -95
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Migrate Tiny News
2
2
 
3
- Export content from Tiny News using JSON files, and generate a `zip` file you can import into a Ghost installation.
3
+ Migrate content from Tiny News using its JSON exports, and generate a `zip` file you can import into a Ghost installation.
4
4
 
5
5
 
6
6
  ## Install
@@ -22,7 +22,7 @@ or
22
22
 
23
23
  ## Usage
24
24
 
25
- To run a Ghost API migration, the required command is:
25
+ To run a Tiny News migration, the required command is:
26
26
 
27
27
  ```sh
28
28
  migrate tinynews --url https://example.com --articles /path/to/articles.json
@@ -30,52 +30,134 @@ migrate tinynews --url https://example.com --articles /path/to/articles.json
30
30
 
31
31
  It's possible to pass more options, in order to achieve a better migration file for Ghost:
32
32
 
33
- - **`--url`** (required)
34
- - string - default: `null`
35
- - URL to live site
36
33
  - **`--articles`** (required)
34
+ - Path to the articles JSON file, an array of articles
35
+ - string - default: `null`
36
+ - **`--url`** (required)
37
+ - URL to the live site. It scopes the stable Ghost IDs and gives newsletters their old URLs
37
38
  - string - default: `null`
38
- - Path to articles JSON file
39
39
  - **`--pages`**
40
+ - Path to the pages JSON file, an array of pages
40
41
  - string - default: `null`
41
- - Path to pages JSON file
42
42
  - **`--newsletters`**
43
+ - Path to the newsletters JSON file, with editions in `data.newsletter_editions`
43
44
  - string - default: `null`
44
- - Path to newsletters JSON file
45
45
  - **`--authors`**
46
+ - Path to the authors JSON file, with authors in `data.authors`
46
47
  - string - default: `null`
47
- - Path to authors JSON file
48
- - **`--verbose`**
49
- - bool - default: `false`
50
- - Show verbose output
51
- - **`--zip`**
52
- - bool - default: `true`
53
- - Create a zip file
54
- - **`--scrape`**
48
+ - **`--scrape`**
55
49
  - Configure scraping tasks
56
- - string - default: `all`
57
- - Choices: `all`, `web`, `assets`, `none`
50
+ - array - default: `all`
51
+ - Choices: `all`, `web`, `assets`, `none` (and `img`, `media`, `files`, aliases of `assets`)
58
52
  - `all`: Scrape web metadata and download assets
59
- - `web`: Only scrape metadata from web pages
53
+ - `web`: Only scrape each published item's description and Open Graph and Twitter titles and descriptions from its page on the live site
60
54
  - `assets`: Only download assets (images, media, files)
61
55
  - `none`: Skip all scraping tasks
62
- - **`--addPrimaryTag`**
63
- - string - default: `null`
64
- - Provide a tag name which should be added to every post as primary tag
65
- - **`--fallBackHTMLCard`**
66
- - bool - default: `true`
67
- - Fall back to convert to HTMLCard, if standard Mobiledoc convert fails
68
- - **`--cache`**
56
+ - **`--wait_after_scrape`**
57
+ - Time in ms to wait after a URL is scraped
58
+ - number - default: `200`
59
+ - **`--rereadSource`**
60
+ - Read the JSON files again, replacing the stored source
61
+ - bool - default: `false`
62
+ - **`--postsPerFile`**
63
+ - Maximum posts written per Ghost import JSON file
64
+ - number - default: `2000`
65
+ - **`--cache`**
69
66
  - Persist local cache after migration is complete (Only if `--zip` is `true`)
70
67
  - bool - default: `true`
68
+ - **`--tmpPath`**
69
+ - Specify the full path where the temporary files will be stored (Defaults a hidden tmp dir)
70
+ - string - default: `null`
71
+ - **`--outputPath`**
72
+ - Specify the full path where the final zip file will be saved to (Defaults to CWD)
73
+ - string - default: `null`
74
+ - **`--cacheName`**
75
+ - Provide a unique name for the cache directory
76
+ - string - default: one based on the input files' full paths
77
+ - **`-V` `--verbose`**
78
+ - Show verbose output
79
+ - bool - default: `false`
80
+ - **`--zip`**
81
+ - Create a zip file
82
+ - bool - default: `true`
83
+ - **`--report`**
84
+ - Write a `.report.json` migration report beside the import, or a `.failed-report.json` if the run fails
85
+ - bool - default: `false`
86
+ - **`--ghostApiUrl`**, **`--ghostAdminKey`**
87
+ - Match authors to existing Ghost users by email
88
+ - string - default: `null`
71
89
 
72
90
  A more complete migration command could look like this:
73
91
 
74
92
  ```sh
75
- migrate tinynews --url http://example.com --articles /path/to/articles.json --pages /path/to/pages.json --newsletters /path/to/newsletters.json --authors /path/to/authors.json
93
+ migrate tinynews --url https://example.com --articles /path/to/articles.json --pages /path/to/pages.json --newsletters /path/to/newsletters.json --authors /path/to/authors.json
76
94
  ```
77
95
 
78
- This will get all posts, pages, newsletters, and authors.
96
+ This will get all articles, pages, newsletters and authors.
97
+
98
+
99
+ ## Output
100
+
101
+ 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.
102
+
103
+ Articles become posts and pages become pages, from their first translation: its headline (trimmed; `(Untitled)` when it has none), published or draft status, search title and description (also the excerpt), Facebook and Twitter titles and descriptions, and main image (its alt text is also the caption; a page's `mainImage` content block takes precedence). Content blocks become HTML: text, headings, quotes, rules, lists and images, and Twitter, TikTok, Facebook, Vimeo, YouTube, Apple Podcasts, Spotify, Instagram and Google Docs embeds. A block that cannot be converted, such as another embed, is left out and reported as a warning. Articles with a Facebook post embed load Facebook's SDK in their code injection. Dates are `first_published_at` (or `last_published_at`) and `last_published_at`; a timestamp without a timezone is read as UTC, and a draft without either is dated when the export was read.
104
+
105
+ Newsletter editions become published posts with their headline, subheadline as the excerpt, cleaned HTML in one HTML card (without the "Made with Letterhead" link or empty paragraphs), and `newsletter_published_at` (or `newsletter_created_at`) as the published date. Their old URL is `<url>/newsletters/<slug>`.
106
+
107
+ An article's or page's author is its first author, with the email, photo and bio of the author with the same first names and last name in the authors file when there is one. Without an author, it is the person in its translation's `created_by_email` (named after the email's local part), then the only author in the authors file, then a default "Author". Newsletters are by "Newsletter". Authors have the Contributor role and, without an email, a `<slug>@example.com` placeholder. Authors are identified by email, or by name when they have none, so names whose slugs collide get distinct slugs and placeholder emails (`jane-doe`, `jane-doe-2`).
108
+
109
+ An article's tags are its category, its tags and `#tinynews`; newsletters are tagged `#newsletter` and `#tinynews`. An unpublished category or tag becomes an internal `#` tag with a `hash-` slug, and internal tags come last. Tags are identified by slug. Links between migrated articles, pages and newsletters point at their new paths.
110
+
111
+ With `--report`, a `.report.json` beside the ZIP (or in the workspace when `--zip false`) lists imported and skipped counts with diagnostics. Items without an ID or slug or without a translation, published items without a valid date, and items with more than 500 tags are skipped and reported, and a page that cannot be scraped is reported as a warning. When every item is invalid, or the run fails, `--report` writes a `.failed-report.json` instead.
112
+
113
+
114
+ ## Source storage
115
+
116
+ The first run stores the JSON files in an `mg-context` SQLite database in the workspace; later runs map the stored items again without reading the files, even if they have moved. Use `--rereadSource` to read them again, such as after adding `--pages`, `--newsletters` or `--authors` to a run with `--cacheName`. Without `--cacheName`, the workspace is keyed by the full path of every input file, so a different set of files never shares stored data.
117
+
118
+ Each file is read one item at a time, so a large articles export is never held in memory. Articles, pages and newsletter editions are stored as `post` records keyed by `article:id:<id>`, `page:id:<id>` and `newsletter:id:<id>` (or `<type>:slug:<slug>` without an ID), and authors as `author` records keyed by `id:<id>` (or `name:<name>`). An item that appears more than once keeps the most recently published copy (the first on a tie) and reports a `source:conflict`. A file with malformed JSON, without its array, or with an item that is not a JSON object is rejected and keeps any stored data. An empty articles array is a valid, empty export.
119
+
120
+ Every option applies when the stored records are mapped, so changing `--url` needs no new read. Ghost IDs derive from `--url` and the item key, tag slug or author email or name, so they stay the same across runs.
121
+
122
+
123
+ ## Programmatic API
124
+
125
+ The package exports `parse`, `ingest` and `map` for use with `@tryghost/mg-context`. The caller owns the context, export and closure:
126
+
127
+ ```js
128
+ import {MigrateContext} from '@tryghost/mg-context';
129
+ import {ingest, map} from '@tryghost/mg-tinynews';
130
+
131
+ const context = new MigrateContext({dbPath: './migration.sqlite'});
132
+ const rereadSource = process.argv.includes('--rereadSource');
133
+ await context.init();
134
+ try {
135
+ if (!context.sources.hasCompletedIngestion || rereadSource) {
136
+ await ingest(
137
+ {articles: '/path/to/articles.json', pages: '/path/to/pages.json', authors: '/path/to/authors.json'},
138
+ context,
139
+ {replace: rereadSource}
140
+ );
141
+ }
142
+ const summary = await map({url: 'https://example.com'}, context);
143
+ for await (const file of context.writeGhostJsonStream('./output', {filename: 'ghost-import'})) {
144
+ // Consume one file descriptor at a time.
145
+ }
146
+ await context.writeMigrationReport('./migration.report.json', summary);
147
+ } finally {
148
+ await context.close();
149
+ }
150
+ ```
151
+
152
+ - `ingest({articles, pages, newsletters, authors}, context, {replace})` reads the given files into `context.sources` inside `context.sources.ingest()`. `articles` is required. Explicit `replace: true` is required when completed source data exists; a failed read keeps the previous data.
153
+ - `parse(input)` yields the same records as `SourceRecordInput` values, one at a time, without storing them.
154
+ - `map({url}, 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 email, posts keep that user's Ghost ID, slug and roles, and Ghost users' slugs are reserved for them.
155
+ - `sourceUrl({url}, record)` gives a stored item's URL on the live site, or `null`. `ghostId(site, kind, key)` gives the stable Ghost ID `map()` uses.
156
+ - `processArticle()`, `processNewsletter()`, `processNewsletterContent()`, `articleTags()`, `personAuthor()` and `emailAuthor()` convert one item's parts. `jsonToHtml(blocks, {onUnhandled})` converts content blocks to HTML, calling `onUnhandled(reason, block)` for each block it leaves out, and the `Entry*` functions convert one block each.
157
+
158
+ The previous default export (`({options})`, which read every file into memory and returned `{posts}` for `toGhostJSON`) and `mapContent()`/`mapPostPageConfig()` have been removed.
159
+
160
+ 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-tinynews-articles-1700000000000.zip` for `articles.json`.
79
161
 
80
162
 
81
163
  ## Develop
@@ -92,13 +174,13 @@ Follow the instructions for the top-level repo.
92
174
  To run a local development copy, `cd` into this directory, and use `pnpm dev` instead of `migrate` like so:
93
175
 
94
176
  ```sh
95
- pnpm dev tinynews [options]
177
+ pnpm dev tinynews --url https://example.com --articles /path/to/articles.json
96
178
  ```
97
179
 
98
180
 
99
181
  ## Test
100
182
 
101
- - `pnpm test` runs the package tests
183
+ - `pnpm test:local` builds the package and runs its tests with 100% coverage
102
184
  - Linting and formatting are run from the repo root (`pnpm lint`, `pnpm format`)
103
185
 
104
186
 
@@ -0,0 +1,8 @@
1
+ export { ingest, parse } from './lib/ingest.js';
2
+ export { ghostId, map, sourceUrl } from './lib/map.js';
3
+ export { articleTags, authorName, emailAuthor, newsletterUrl, personAuthor, processArticle, processNewsletter, processNewsletterContent, textOnly } from './lib/process.js';
4
+ export { jsonToHtml, formatChildStyles, EntryList, EntryText, EntryImage, EntryHeading, EntryBlockquote, EntryHorizontalRule, EntryTwitterEmbed, EntryTikTokEmbed, EntryFacebookEmbed, EntryVimeoEmbed, EntryYoutubeEmbed, EntryApplePodcastsEmbed, EntryInstagramPostEmbed, EntryInstagramReelEmbed, EntryGoogleDocsEmbed, EntrySpotifyEmbed } from './lib/json-to-html.js';
5
+ export type { JsonToHtmlOptions } from './lib/json-to-html.js';
6
+ export type { MappingServices, MappingSummary } from './lib/map.js';
7
+ export type { ProcessedAuthor, ProcessedPost, ProcessedTag } from './lib/process.js';
8
+ export type { TinyNewsArticle, TinyNewsAuthor, TinyNewsBlock, TinyNewsChild, TinyNewsInput, TinyNewsNewsletter, TinyNewsOptions, TinyNewsTag, TinyNewsTranslation } from './lib/types.js';
package/build/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { ingest, parse } from './lib/ingest.js';
2
+ export { ghostId, map, sourceUrl } from './lib/map.js';
3
+ export { articleTags, authorName, emailAuthor, newsletterUrl, personAuthor, processArticle, processNewsletter, processNewsletterContent, textOnly } from './lib/process.js';
4
+ export { jsonToHtml, formatChildStyles, EntryList, EntryText, EntryImage, EntryHeading, EntryBlockquote, EntryHorizontalRule, EntryTwitterEmbed, EntryTikTokEmbed, EntryFacebookEmbed, EntryVimeoEmbed, EntryYoutubeEmbed, EntryApplePodcastsEmbed, EntryInstagramPostEmbed, EntryInstagramReelEmbed, EntryGoogleDocsEmbed, EntrySpotifyEmbed } from './lib/json-to-html.js';
5
+ //# 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,OAAO,EAAE,GAAG,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AACrD,OAAO,EACH,WAAW,EACX,UAAU,EACV,WAAW,EACX,aAAa,EACb,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,wBAAwB,EACxB,QAAQ,EACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,UAAU,EACV,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACpB,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { MigrateContext, SourceRecordInput } from '@tryghost/mg-context';
2
+ import type { TinyNewsInput } from './types.js';
3
+ /**
4
+ * Yield the originals of a Tiny News export one at a time without storing them. The articles and pages files are
5
+ * JSON arrays, read one item at a time; newsletter editions are read from `data.newsletter_editions` and authors from
6
+ * `data.authors`. Articles, pages and newsletters are `post` records whose metadata `type` is `article`, `page` or
7
+ * `newsletter`; authors are `author` records. Rejects input without an articles file, malformed JSON, or an item that
8
+ * is not a JSON object.
9
+ */
10
+ export declare function parse(input: TinyNewsInput): AsyncGenerator<SourceRecordInput>;
11
+ /**
12
+ * Read a Tiny News export into `context.sources`. An item that appears more than once keeps the most recently
13
+ * published version (the first on a tie) and reports a `source:conflict` when the versions differ. Explicit
14
+ * `replace: true` is required when completed source data exists; a failed read keeps the previous data.
15
+ */
16
+ export declare function ingest(input: TinyNewsInput, context: MigrateContext, { replace }?: {
17
+ replace?: boolean;
18
+ }): Promise<void>;
@@ -0,0 +1,91 @@
1
+ import { basename, resolve } from 'node:path';
2
+ import fsUtils from '@tryghost/mg-fs-utils';
3
+ import { authorName, text } from './process.js';
4
+ /** What each input file holds, and the keys leading to its array. */
5
+ const FILES = [
6
+ { option: 'articles', type: 'article', kind: 'post', path: [] },
7
+ { option: 'pages', type: 'page', kind: 'post', path: [] },
8
+ { option: 'newsletters', type: 'newsletter', kind: 'post', path: ['data', 'newsletter_editions'] },
9
+ { option: 'authors', type: 'author', kind: 'author', path: ['data', 'authors'] }
10
+ ];
11
+ /** The input files given, in reading order. Rejects input without an articles file. */
12
+ function inputFiles(input) {
13
+ if (!text(input.articles)) {
14
+ throw new Error('Tiny News ingestion needs an articles JSON file (--articles).');
15
+ }
16
+ return FILES.filter(spec => text(input[spec.option])).map(spec => ({ spec, path: input[spec.option] }));
17
+ }
18
+ /** A Tiny News ID: a number, or a nonblank string. */
19
+ function id(value) {
20
+ return typeof value === 'number' && Number.isFinite(value) ? String(value) : text(value);
21
+ }
22
+ /**
23
+ * An item's key: `<type>:id:<id>` for an article, page or newsletter (`<type>:slug:<slug>` without an ID), and
24
+ * `id:<id>` for an author (`name:<name>` without an ID). `null` when the item has none of these.
25
+ */
26
+ function key(spec, item) {
27
+ const itemId = id(item.id);
28
+ if (spec.kind === 'author') {
29
+ const name = authorName(item);
30
+ return itemId ? `id:${itemId}` : name ? `name:${name}` : null;
31
+ }
32
+ const slug = text(item.slug);
33
+ return itemId ? `${spec.type}:id:${itemId}` : slug ? `${spec.type}:slug:${slug}` : null;
34
+ }
35
+ /**
36
+ * Yield the originals of a Tiny News export one at a time without storing them. The articles and pages files are
37
+ * JSON arrays, read one item at a time; newsletter editions are read from `data.newsletter_editions` and authors from
38
+ * `data.authors`. Articles, pages and newsletters are `post` records whose metadata `type` is `article`, `page` or
39
+ * `newsletter`; authors are `author` records. Rejects input without an articles file, malformed JSON, or an item that
40
+ * is not a JSON object.
41
+ */
42
+ export async function* parse(input) {
43
+ for (const { spec, path } of inputFiles(input)) {
44
+ const file = basename(resolve(path));
45
+ let index = 0;
46
+ try {
47
+ for await (const item of fsUtils.json.streamArray(path, { path: spec.path })) {
48
+ if (!item || typeof item !== 'object' || Array.isArray(item)) {
49
+ throw new Error(`${file}: item ${index} is not a Tiny News ${spec.type}`);
50
+ }
51
+ yield {
52
+ kind: spec.kind,
53
+ key: key(spec, item),
54
+ content: JSON.stringify(item),
55
+ format: 'json',
56
+ metadata: { file, type: spec.type, index }
57
+ };
58
+ index += 1;
59
+ }
60
+ }
61
+ catch (error) {
62
+ if (error instanceof SyntaxError) {
63
+ throw new SyntaxError(`${file}: ${error.message}`, { cause: error });
64
+ }
65
+ throw error;
66
+ }
67
+ }
68
+ }
69
+ /** The last time a post was published, or NaN for an author or an undated post. */
70
+ const updated = (content) => {
71
+ const item = JSON.parse(content);
72
+ return Date.parse(item.translations?.[0]?.last_published_at ?? item.newsletter_published_at);
73
+ };
74
+ /** The more recently published version of a post wins; a tie, an undated post or an author keeps the earlier one. */
75
+ function newer(existing, incoming) {
76
+ return updated(incoming.content) > updated(existing.content) ? 'replace' : 'keep';
77
+ }
78
+ /**
79
+ * Read a Tiny News export into `context.sources`. An item that appears more than once keeps the most recently
80
+ * published version (the first on a tie) and reports a `source:conflict` when the versions differ. Explicit
81
+ * `replace: true` is required when completed source data exists; a failed read keeps the previous data.
82
+ */
83
+ export async function ingest(input, context, { replace = false } = {}) {
84
+ const files = Object.fromEntries(inputFiles(input).map(({ spec, path }) => [spec.option, basename(resolve(path))]));
85
+ await context.sources.ingest({ replace, metadata: { adapter: 'tinynews', files } }, async (stage) => {
86
+ for await (const record of parse(input)) {
87
+ stage.reconcile(record, { choose: newer });
88
+ }
89
+ });
90
+ }
91
+ //# 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,OAAO,EAAC,MAAM,WAAW,CAAC;AAC5C,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAC,UAAU,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAG9C,q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pB,OAAuB,EACvB,EAAC,OAAO,GAAG,KAAK,EAAC,GAAwB,EAAE;IAE3C,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAE,IAAI,EAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClH,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,EAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAC,EAAC,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE;QAC1F,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACtC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC;QAC7C,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { TinyNewsBlock, TinyNewsChild } from './types.js';
2
+ type Block = TinyNewsBlock;
3
+ type EmbedBlock = TinyNewsBlock & {
4
+ link: string;
5
+ };
6
+ export interface JsonToHtmlOptions {
7
+ /** Called with a reason for each block that cannot be converted. The block is left out of the HTML. */
8
+ onUnhandled?: (reason: string, block: TinyNewsBlock) => void;
9
+ }
10
+ /** A run of text with its link and bold, italic and underline styles. */
11
+ declare const formatChildStyles: (child: TinyNewsChild) => string;
12
+ declare const EntryList: (block: Block) => string;
13
+ declare const EntryText: (block: Block) => string | null;
14
+ declare const EntryImage: (block: Block) => string;
15
+ declare const EntryHeading: (block: Block) => string | null;
16
+ /** A block quote of the block's nonblank children, or nothing when every child is blank. */
17
+ declare const EntryBlockquote: (block: Block) => string;
18
+ declare const EntryHorizontalRule: (_block?: Block) => string;
19
+ declare const EntryTwitterEmbed: (block: EmbedBlock) => string;
20
+ declare const EntryTikTokEmbed: (block: EmbedBlock) => string;
21
+ declare const EntryFacebookEmbed: (block: EmbedBlock) => string;
22
+ declare const EntryVimeoEmbed: (block: EmbedBlock) => string;
23
+ declare const EntryYoutubeEmbed: (block: EmbedBlock) => string;
24
+ declare const EntryApplePodcastsEmbed: (block: EmbedBlock) => string;
25
+ declare const EntryInstagramPostEmbed: (block: EmbedBlock) => string;
26
+ declare const EntryInstagramReelEmbed: (block: EmbedBlock) => string;
27
+ declare const EntryGoogleDocsEmbed: (block: EmbedBlock) => string;
28
+ declare const EntrySpotifyEmbed: (block: EmbedBlock) => string;
29
+ /**
30
+ * Convert an article's content blocks to HTML. A string is already HTML and is returned as it is. Blocks that cannot
31
+ * be converted are left out and passed to `onUnhandled`, as is a `mainImage` block: the feature image comes from the
32
+ * article instead.
33
+ */
34
+ declare const jsonToHtml: (blocks: TinyNewsBlock[] | string | null | undefined, { onUnhandled }?: JsonToHtmlOptions) => string;
35
+ export { jsonToHtml, formatChildStyles, EntryList, EntryText, EntryImage, EntryHeading, EntryBlockquote, EntryHorizontalRule, EntryTwitterEmbed, EntryTikTokEmbed, EntryFacebookEmbed, EntryVimeoEmbed, EntryYoutubeEmbed, EntryApplePodcastsEmbed, EntryInstagramPostEmbed, EntryInstagramReelEmbed, EntryGoogleDocsEmbed, EntrySpotifyEmbed };
@@ -0,0 +1,238 @@
1
+ import SimpleDom from 'simple-dom';
2
+ import { cardUtils } from '@tryghost/mg-utils';
3
+ import { TextNode } from './text.js';
4
+ const serializer = new SimpleDom.HTMLSerializer(SimpleDom.voidMap);
5
+ const imageCard = cardUtils.getCard('image');
6
+ // From https://gist.github.com/takien/4077195
7
+ const getYouTubeID = (url) => {
8
+ const arr = url.split(/(vi\/|v%3D|v=|\/v\/|youtu\.be\/|\/embed\/)/);
9
+ return undefined !== arr[2] ? arr[2].split(/[^\w-]/i)[0] : arr[0];
10
+ };
11
+ /** A run of text with its link and bold, italic and underline styles. */
12
+ const formatChildStyles = (child) => {
13
+ const style = child.style ?? {};
14
+ let html = child.content ?? '';
15
+ if (style.underline) {
16
+ html = `<u>${html}</u>`;
17
+ }
18
+ if (style.italic) {
19
+ html = `<em>${html}</em>`;
20
+ }
21
+ if (style.bold) {
22
+ html = `<strong>${html}</strong>`;
23
+ }
24
+ if (child.link) {
25
+ html = `<a href="${child.link}">${html}</a>`;
26
+ }
27
+ return html;
28
+ };
29
+ const EntryList = (block) => {
30
+ const listTypeEl = block.listType === 'NUMBER' ? 'ol' : 'ul';
31
+ let html = [];
32
+ html.push(`<${listTypeEl}>`);
33
+ (block.items ?? []).forEach(item => {
34
+ (item.children ?? []).forEach(child => {
35
+ html.push(`<li>${formatChildStyles(child)}</li>`);
36
+ });
37
+ });
38
+ html.push(`</${listTypeEl}>`);
39
+ return html.join('');
40
+ };
41
+ const EntryText = (block) => {
42
+ return TextNode({ node: block });
43
+ };
44
+ const EntryImage = (block) => {
45
+ let html = [];
46
+ (block.children ?? []).forEach(child => {
47
+ let cardOpts = {
48
+ env: { dom: new SimpleDom.Document() },
49
+ payload: {
50
+ src: child.imageUrl,
51
+ alt: child.imageAlt,
52
+ caption: child.imageAlt
53
+ }
54
+ };
55
+ if (block.link) {
56
+ cardOpts.payload.href = block.link;
57
+ }
58
+ html.push(serializer.serialize(imageCard.render(cardOpts)));
59
+ });
60
+ return html.join('');
61
+ };
62
+ const EntryHeading = (block) => {
63
+ return TextNode({ node: block });
64
+ };
65
+ /** A block quote of the block's nonblank children, or nothing when every child is blank. */
66
+ const EntryBlockquote = (block) => {
67
+ const children = (block.children ?? []).filter(child => child.content?.trim());
68
+ if (!children.length) {
69
+ return '';
70
+ }
71
+ return `<blockquote><p>${children.map(formatChildStyles).join('')}</p></blockquote>`;
72
+ };
73
+ const EntryHorizontalRule = (_block) => '<hr>';
74
+ const EntryTwitterEmbed = (block) => {
75
+ const blockHtml = `<figure class="kg-card kg-embed-card"><blockquote class="twitter-tweet"><a href="${block.link}"></a></blockquote><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></figure>`;
76
+ return blockHtml;
77
+ };
78
+ const EntryTikTokEmbed = (block) => {
79
+ const usernameRegexp = new RegExp('(?<username>@[a-zA-Z0-9-_]+)');
80
+ const usernameMatches = block.link.match(usernameRegexp);
81
+ const videoIDRegexp = new RegExp('(?<videoID>[0-9]{10,})');
82
+ const videoIDMatches = block.link.match(videoIDRegexp);
83
+ if (usernameMatches && videoIDMatches) {
84
+ const username = usernameMatches.groups.username;
85
+ const videoID = videoIDMatches.groups.videoID;
86
+ return `<figure class="kg-card kg-embed-card"><blockquote class="tiktok-embed" cite="https://www.tiktok.com/${username}/video/${videoID}" data-video-id="${videoID}" style="max-width: 605px;min-width: 325px;"><section><a target="_blank" title="${username}" href="https://www.tiktok.com/${username}?refer=embed">${username}</a></section></blockquote><script async src="https://www.tiktok.com/embed.js"></script></figure>`;
87
+ }
88
+ else {
89
+ return `<p><a href="${block.link}">${block.link}</a></p>`;
90
+ }
91
+ };
92
+ const EntryFacebookEmbed = (block) => {
93
+ if (block.html) {
94
+ const blockHtml = `<!--kg-card-begin: html-->${block.html}<!--kg-card-end: html-->`;
95
+ return blockHtml;
96
+ }
97
+ else {
98
+ return `<p><a href="${block.link}">${block.link}</a></p>`;
99
+ }
100
+ };
101
+ const EntryVimeoEmbed = (block) => {
102
+ const videoIDRegexp = new RegExp('(?<videoID>[0-9]{3,})');
103
+ const videoIDMatches = block.link.match(videoIDRegexp);
104
+ if (videoIDMatches) {
105
+ const blockHtml = `<iframe src="https://player.vimeo.com/video/${videoIDMatches.groups.videoID}" width="160" height="90" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>`;
106
+ return blockHtml;
107
+ }
108
+ else {
109
+ return `<p><a href="${block.link}">${block.link}</a></p>`;
110
+ }
111
+ };
112
+ const EntryYoutubeEmbed = (block) => {
113
+ const videoID = getYouTubeID(block.link);
114
+ const blockHtml = `<iframe width="160" height="90" src="https://www.youtube.com/embed/${videoID}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>`;
115
+ return blockHtml;
116
+ };
117
+ const EntryApplePodcastsEmbed = (block) => {
118
+ const iframeSrc = block.link.replace('https://podcasts.apple.com', 'https://embed.podcasts.apple.com');
119
+ const blockHtml = `<iframe allow="autoplay *; encrypted-media *; fullscreen *; clipboard-write" frameborder="0" height="450" style="width:100%;max-width:660px;overflow:hidden;border-radius:10px;" sandbox="allow-forms allow-popups allow-same-origin allow-scripts allow-storage-access-by-user-activation allow-top-navigation-by-user-activation" src="${iframeSrc}"></iframe>`;
120
+ return blockHtml;
121
+ };
122
+ const EntryInstagramPostEmbed = (block) => {
123
+ const blockHtml = `<iframe src="${block.link}embed/captioned/" class="instagram-media" allowtransparency="true" allowfullscreen="true" frameborder="0" scrolling="no" style="background: white; max-width: 658px; width: calc(100% - 2px); border-radius: 3px; border: 1px solid rgb(219, 219, 219); box-shadow: none; display: block; margin: 0px; min-width: 326px; padding: 0px;"></iframe><script async="" src="//www.instagram.com/embed.js"></script>`;
124
+ return blockHtml;
125
+ };
126
+ const EntryInstagramReelEmbed = (block) => {
127
+ const blockHtml = `<iframe class="instagram-media" src="${block.link}embed/captioned/" allowtransparency="true" allowfullscreen="true" frameborder="0" scrolling="no" style="background: white; max-width: 540px; width: calc(100% - 2px); border-radius: 3px; border: 1px solid rgb(219, 219, 219); box-shadow: none; display: block; margin: 0px; min-width: 326px; padding: 0px; position: relative;"></iframe><script async="" src="//www.instagram.com/embed.js"></script>`;
128
+ return blockHtml;
129
+ };
130
+ const EntryGoogleDocsEmbed = (block) => {
131
+ const blockHtml = `<iframe class="googledocs-embed" src="${block.link}" allowtransparency="true" allowfullscreen="true" frameborder="0" style="width: 100%; height: 500px;"></iframe>`;
132
+ return blockHtml;
133
+ };
134
+ const EntrySpotifyEmbed = (block) => {
135
+ let embedUrl = block.link.replace('https://open.spotify.com/episode/', 'https://open.spotify.com/embed/episode/');
136
+ embedUrl = embedUrl.replace('https://open.spotify.com/show/', 'https://open.spotify.com/embed/show/');
137
+ const blockHtml = `<iframe src="${embedUrl}" width="300" height="380" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>`;
138
+ return blockHtml;
139
+ };
140
+ const HEADING_STYLES = ['TITLE', 'SUBTITLE', 'HEADING_1', 'HEADING_2', 'HEADING_3', 'HEADING_4'];
141
+ /** The embed for a link, by host and path, or `undefined` when the link is not a supported embed. */
142
+ const embedFor = (block) => {
143
+ const embedUrl = URL.parse(block.link);
144
+ if (!embedUrl) {
145
+ return undefined;
146
+ }
147
+ const { hostname: embedHost, pathname: embedPath } = embedUrl;
148
+ if (embedHost === 'twitter.com') {
149
+ return EntryTwitterEmbed;
150
+ }
151
+ else if (embedHost === 'www.tiktok.com') {
152
+ return EntryTikTokEmbed;
153
+ }
154
+ else if (embedHost === 'www.facebook.com') {
155
+ return EntryFacebookEmbed;
156
+ }
157
+ else if (embedHost === 'vimeo.com') {
158
+ return EntryVimeoEmbed;
159
+ }
160
+ else if (embedHost === 'www.youtube.com' || embedHost === 'youtu.be') {
161
+ return EntryYoutubeEmbed;
162
+ }
163
+ else if (embedHost === 'podcasts.apple.com') {
164
+ return EntryApplePodcastsEmbed;
165
+ }
166
+ else if (embedHost === 'open.spotify.com' &&
167
+ (embedPath.startsWith('/episode/') || embedPath.startsWith('/show/'))) {
168
+ return EntrySpotifyEmbed;
169
+ }
170
+ else if (embedHost === 'www.instagram.com' && embedPath.startsWith('/p/')) {
171
+ return EntryInstagramPostEmbed;
172
+ }
173
+ else if (embedHost === 'www.instagram.com' && embedPath.startsWith('/reel/')) {
174
+ return EntryInstagramReelEmbed;
175
+ }
176
+ else if (embedHost === 'docs.google.com') {
177
+ return EntryGoogleDocsEmbed;
178
+ }
179
+ return undefined;
180
+ };
181
+ /**
182
+ * Convert an article's content blocks to HTML. A string is already HTML and is returned as it is. Blocks that cannot
183
+ * be converted are left out and passed to `onUnhandled`, as is a `mainImage` block: the feature image comes from the
184
+ * article instead.
185
+ */
186
+ const jsonToHtml = (blocks, { onUnhandled = () => { } } = {}) => {
187
+ let html = [];
188
+ if (typeof blocks === 'string') {
189
+ return blocks;
190
+ }
191
+ (blocks ?? []).forEach(block => {
192
+ const itemType = block.type ?? null;
193
+ const itemStyle = block.style ?? null;
194
+ if (itemType === 'mainImage') {
195
+ // This element is skipped as we use the top level 'featured_image' instead
196
+ // Using this would result in duplicates
197
+ return;
198
+ }
199
+ if (itemType === 'text') {
200
+ if (itemStyle && HEADING_STYLES.includes(itemStyle)) {
201
+ html.push(EntryHeading(block));
202
+ }
203
+ else if (itemStyle === 'NORMAL_TEXT') {
204
+ html.push(EntryText(block));
205
+ }
206
+ else {
207
+ onUnhandled(`Unhandled text style: ${itemStyle}`, block);
208
+ }
209
+ }
210
+ else if (itemType === 'blockquote') {
211
+ html.push(EntryBlockquote(block));
212
+ }
213
+ else if (itemType === 'hr') {
214
+ html.push(EntryHorizontalRule());
215
+ }
216
+ else if (itemType === 'list') {
217
+ html.push(EntryList(block));
218
+ }
219
+ else if (itemType === 'image') {
220
+ html.push(EntryImage(block));
221
+ }
222
+ else if (itemType === 'embed') {
223
+ const embed = typeof block.link === 'string' ? embedFor(block) : undefined;
224
+ if (embed) {
225
+ html.push(embed(block));
226
+ }
227
+ else {
228
+ onUnhandled(`Unhandled embed: ${block.link}`, block);
229
+ }
230
+ }
231
+ else {
232
+ onUnhandled(`Unhandled block type: ${itemType}`, block);
233
+ }
234
+ });
235
+ return html.join('');
236
+ };
237
+ export { jsonToHtml, formatChildStyles, EntryList, EntryText, EntryImage, EntryHeading, EntryBlockquote, EntryHorizontalRule, EntryTwitterEmbed, EntryTikTokEmbed, EntryFacebookEmbed, EntryVimeoEmbed, EntryYoutubeEmbed, EntryApplePodcastsEmbed, EntryInstagramPostEmbed, EntryInstagramReelEmbed, EntryGoogleDocsEmbed, EntrySpotifyEmbed };
238
+ //# sourceMappingURL=json-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