@tryghost/mg-substack 0.5.0 → 0.5.1

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 (2) hide show
  1. package/lib/process.js +76 -0
  2. package/package.json +3 -3
package/lib/process.js CHANGED
@@ -396,6 +396,82 @@ const processContent = (post, siteUrl, options) => {
396
396
  $(anchor).replaceWith(serializer.serialize(imageCard.render(cardOpts)));
397
397
  });
398
398
 
399
+ $html('.digest-post-embed').each((i, el) => {
400
+ const attrsRaw = $(el).attr('data-attrs');
401
+ const attrs = JSON.parse(attrsRaw);
402
+
403
+ let theHtml = [];
404
+
405
+ if (attrs.section_name) {
406
+ theHtml.push(`<h6>${attrs.section_name}</h6>`);
407
+ }
408
+
409
+ if (attrs.title) {
410
+ theHtml.push(`<h3>`);
411
+
412
+ if (attrs.canonical_url) {
413
+ theHtml.push(`<a href="${attrs.canonical_url}">`);
414
+ }
415
+
416
+ theHtml.push(attrs.title);
417
+
418
+ if (attrs.canonical_url) {
419
+ theHtml.push(`</a>`);
420
+ }
421
+
422
+ theHtml.push(`</h3>`);
423
+ }
424
+
425
+ if (attrs.publishedBylines.length || attrs.post_date) {
426
+ theHtml.push(`<p>`);
427
+
428
+ if (attrs.publishedBylines) {
429
+ let bylines = [];
430
+
431
+ attrs.publishedBylines.forEach((byline) => {
432
+ bylines.push(byline.name);
433
+ });
434
+
435
+ theHtml.push(bylines.join(', '));
436
+ }
437
+
438
+ if (attrs.publishedBylines.length && attrs.post_date) {
439
+ theHtml.push(` &bull; `);
440
+ }
441
+
442
+ if (attrs.post_date) {
443
+ theHtml.push(new Date(attrs.post_date).toLocaleString('en-US', {month: 'short', day: 'numeric', year: 'numeric'}));
444
+ }
445
+
446
+ theHtml.push(`</p>`);
447
+ }
448
+
449
+ if (attrs.cover_image) {
450
+ if (attrs.canonical_url) {
451
+ theHtml.push(`<a href="${attrs.canonical_url}">`);
452
+ }
453
+
454
+ theHtml.push(`<img src="${attrs.cover_image}" alt="${attrs.cover_image_alt || ''}">`);
455
+
456
+ if (attrs.canonical_url) {
457
+ theHtml.push(`</a>`);
458
+ }
459
+ }
460
+
461
+ if (attrs.caption) {
462
+ theHtml.push(`<p>`);
463
+ theHtml.push(attrs.caption);
464
+
465
+ if (attrs.canonical_url) {
466
+ theHtml.push(`<br><br><a href="${attrs.canonical_url}">Read full story &rarr;</a>`);
467
+ }
468
+
469
+ theHtml.push(`</p>`);
470
+ }
471
+
472
+ $(el).replaceWith(theHtml.join(''));
473
+ });
474
+
399
475
  $html('a > style').each((i, style) => {
400
476
  $(style).remove();
401
477
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-substack",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-substack",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "html-entities": "2.4.0",
37
37
  "lodash": "4.17.21",
38
38
  "simple-dom": "1.4.0",
39
- "srcset": "5.0.0"
39
+ "srcset": "5.0.1"
40
40
  },
41
- "gitHead": "d0c6f970f484101ab9b4dcf8ba95fa1398da4b79"
41
+ "gitHead": "db762af916ae75789b139f59220b621ec9d732c7"
42
42
  }