trell-story-json-to-amp
Advanced tools
Comparing version 2.0.12 to 2.0.13
@@ -6,8 +6,6 @@ 'use strict'; | ||
}); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var TRELL_DESCRIPTION = 'Share and Spill the secrets of your travel stories and local adventuresto create a beautiful collection of your delicious food blogs and travelogues. Inspire newbies to follow your trails along with your hidden gems and exciting explorations by giving your blog a visual twist and evolving into Google search answers. | Trell.co'; | ||
function getMetaTags(storyMeta) { | ||
console.log('getMetaTags -> storyMeta', storyMeta); | ||
var title = storyMeta.title, | ||
@@ -25,20 +23,15 @@ _storyMeta$author = storyMeta.author, | ||
return '\n <meta name="description" content="' + author + ' | ' + title + ' | ' + TRELL_DESCRIPTION + '">\n\n <meta property="og:title" content="' + title + '" />\n <meta property="og:type" content="article" />\n <meta property="og:url" content="' + canonicalUrl + '" />\n <meta property="og:image" content="' + (images[0] || '') + '" />\n <meta property="og:site_name" content="Trell" />\n\n <meta name="twitter:card" content="summary_large_image">\n <meta name="twitter:site" content="@TrellApp">\n <meta name="twitter:creator" content="@TrellApp">\n <meta name="twitter:title" content="' + title + '">\n <meta name="twitter:description" content="' + author + ' | ' + title + ' | ' + TRELL_DESCRIPTION + '">\n <meta name="twitter:image" content="' + (images[0] || '') + '">\n\n <link rel="shortcut icon" href="https://amp.trell.co/favicon.ico">\n '; | ||
return '\n <meta name="description" content="' + title + ' | by ' + author.name + ' | ' + TRELL_DESCRIPTION + '">\n\n <meta property="og:title" content="' + title + '" />\n <meta property="og:type" content="article" />\n <meta property="og:url" content="' + canonicalUrl + '" />\n <meta property="og:image" content="' + (images[0] || '') + '" />\n <meta property="og:site_name" content="Trell" />\n\n <meta name="twitter:card" content="summary_large_image">\n <meta name="twitter:site" content="@TrellApp">\n <meta name="twitter:creator" content="@TrellApp">\n <meta name="twitter:title" content="' + title + '">\n <meta name="twitter:description" content="' + title + ' | by ' + author.name + ' | ' + TRELL_DESCRIPTION + '">\n <meta name="twitter:image" content="' + (images[0] || '') + '">\n\n <link rel="shortcut icon" href="https://amp.trell.co/favicon.ico">\n '; | ||
} | ||
exports.default = function (storyMeta) { | ||
var schemaType = storyMeta.schemaType; | ||
var schemaType = storyMeta.schemaType, | ||
jsonld = storyMeta.jsonld; | ||
var json = {}; | ||
if (schemaType === 'VIDEO') { | ||
json = videoObjectMeta(storyMeta); | ||
} else if (schemaType === 'NEWS') { | ||
json = newsArticleMeta(storyMeta); | ||
} else { | ||
if (!jsonld) { | ||
throw new Error('Invalid schema type ' + schemaType + ', Valid schema types are VIDEO and NEWS'); | ||
} | ||
return '\n ' + getMetaTags(storyMeta) + '\n <script type="application/ld+json">\n ' + JSON.stringify(json) + '\n </script>'; | ||
return '\n ' + getMetaTags(storyMeta) + '\n <script type="application/ld+json">\n ' + JSON.stringify(jsonld) + '\n </script>'; | ||
}; | ||
@@ -60,10 +53,8 @@ | ||
'@type': 'NewsArticle', | ||
mainEntityOfPage: { | ||
'@type': 'WebPage', | ||
'@id': canonicalUrl | ||
}, | ||
headline: title, | ||
description: description, | ||
image: images && images.length && images, | ||
datePublished: datePublished, | ||
dateModified: dateModified, | ||
publisher: publisher, | ||
author: author && { | ||
@@ -73,17 +64,8 @@ '@type': 'Person', | ||
}, | ||
description: description | ||
mainEntityOfPage: { | ||
'@type': 'WebPage', | ||
'@id': canonicalUrl | ||
} | ||
}; | ||
if (publisher) { | ||
json.publisher = { | ||
publisher: { | ||
'@type': 'Organization', | ||
name: publisher.name, | ||
logo: _extends({ | ||
'@type': 'ImageObject' | ||
}, publisher.logo) | ||
} | ||
}; | ||
} | ||
return json; | ||
@@ -104,2 +86,3 @@ } | ||
videoUrl = storyMeta.videoUrl, | ||
canonicalUrl = storyMeta.canonicalUrl, | ||
ISO8601Duration = storyMeta.ISO8601Duration, | ||
@@ -117,6 +100,2 @@ ISO8601Publish = storyMeta.ISO8601Publish, | ||
'@type': 'VideoObject', | ||
// mainEntityOfPage: { ????? | ||
// '@type': 'WebPage', ????? | ||
// '@id': canonicalUrl, ????? | ||
// }, | ||
name: title, | ||
@@ -129,4 +108,2 @@ description: description, | ||
embedUrl: videoUrl, // should this be different than contentURL | ||
width: '100 px', // height ? | ||
height: '100 px', // width ? | ||
interactionStatistic: [{ | ||
@@ -141,3 +118,3 @@ '@type': 'InteractionCounter', | ||
}], | ||
publisher: publisher, | ||
creator: { | ||
@@ -148,78 +125,12 @@ '@type': 'Person', | ||
alternateName: authorHandle | ||
// TODO: Author stats (Integrate API for that) | ||
// interactionStatistic: [ | ||
// { | ||
// '@type': 'InteractionCounter', | ||
// interactionType: { '@type': 'http://schema.org/LikeAction' }, | ||
// userInteractionCount: 5000, | ||
// }, | ||
// { | ||
// '@type': 'InteractionCounter', | ||
// interactionType: { '@type': 'http://schema.org/FollowAction' }, | ||
// userInteractionCount: 10000, | ||
// }, | ||
// ], | ||
}, | ||
commentCount: comments, | ||
comment: comment | ||
// TODO: Comment list (Top 10 comments maybe ?) | ||
// comment: [ | ||
// { | ||
// '@type': 'Comment', | ||
// text: 'Awesome video!', | ||
// creator: { | ||
// '@type': 'Person', | ||
// name: 'Jane Doe', | ||
// url: 'https://www.example.com/user/jdoe', | ||
// }, | ||
// interactionStatistic: { | ||
// '@type': 'InteractionCounter', | ||
// interactionType: { '@type': 'http://schema.org/LikeAction' }, | ||
// userInteractionCount: 10, | ||
// }, | ||
// }, | ||
// { | ||
// '@type': 'Comment', | ||
// text: 'Love this!', | ||
// creator: { | ||
// '@type': 'Person', | ||
// name: 'Adam', | ||
// url: 'https://www.example.com/user/adamiscool', | ||
// }, | ||
// interactionStatistic: { | ||
// '@type': 'InteractionCounter', | ||
// interactionType: { '@type': 'http://schema.org/LikeAction' }, | ||
// userInteractionCount: 5, | ||
// }, | ||
// }, | ||
// { | ||
// '@type': 'Comment', | ||
// text: 'So cool!', | ||
// creator: { | ||
// '@type': 'Person', | ||
// name: 'Eve', | ||
// url: 'https://www.example.com/user/eve99', | ||
// }, | ||
// interactionStatistic: { | ||
// '@type': 'InteractionCounter', | ||
// interactionType: { '@type': 'http://schema.org/LikeAction' }, | ||
// userInteractionCount: 2, | ||
// }, | ||
// }, | ||
// ], | ||
comment: comment, | ||
mainEntityOfPage: { | ||
'@type': 'WebPage', | ||
'@id': canonicalUrl | ||
} | ||
}; | ||
if (json.publisher) { | ||
json.publisher = { | ||
publisher: { | ||
'@type': 'Organization', | ||
name: publisher.name, | ||
logo: _extends({ | ||
'@type': 'ImageObject' | ||
}, publisher.logo) | ||
} | ||
}; | ||
} | ||
return json; | ||
} |
{ | ||
"name": "trell-story-json-to-amp", | ||
"version": "2.0.12", | ||
"version": "2.0.13", | ||
"description": "Convert story JSON to STAMP HTML.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45992
957