Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

trell-story-json-to-amp

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trell-story-json-to-amp - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

150

dist/render-meta.js

@@ -28,2 +28,19 @@ 'use strict';

exports.default = function (storyMeta) {
var schemaType = storyMeta.schemaType;
var json = {};
if (schemaType === 'VIDEO') {
json = videoObjectMeta(storyMeta);
} else if (schemaType === 'NEWS') {
json = newsArticleMeta(storyMeta);
} else {
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>';
};
function newsArticleMeta(storyMeta) {
var title = storyMeta.title,

@@ -69,3 +86,132 @@ canonicalUrl = storyMeta.canonicalUrl,

return '\n ' + getMetaTags(storyMeta) + '\n <script type="application/ld+json">\n ' + JSON.stringify(json) + '\n </script>';
};
return json;
}
function videoObjectMeta(storyMeta) {
var title = storyMeta.title,
canonicalUrl = storyMeta.canonicalUrl,
_storyMeta$images2 = storyMeta.images,
images = _storyMeta$images2 === undefined ? [] : _storyMeta$images2,
_storyMeta$author2 = storyMeta.author,
authorName = _storyMeta$author2.name,
authorHandle = _storyMeta$author2.handle,
profileLink = _storyMeta$author2.profileLink,
publisher = storyMeta.publisher,
description = storyMeta.description,
videoUrl = storyMeta.videoUrl,
ISO8601Duration = storyMeta.ISO8601Duration,
ISO8601Publish = storyMeta.ISO8601Publish,
_storyMeta$videoStats = storyMeta.videoStats,
loves = _storyMeta$videoStats.loves,
views = _storyMeta$videoStats.views,
comments = _storyMeta$videoStats.comments;
// verify if properties exist
var json = {
'@context': 'https://schema.org',
'@type': 'VideoObject',
// mainEntityOfPage: { ?????
// '@type': 'WebPage', ?????
// '@id': canonicalUrl, ?????
// },
name: title,
description: description,
thumbnailUrl: images,
uploadDate: ISO8601Publish, // ISO 8601
duration: ISO8601Duration, // ISO 8601
contentUrl: videoUrl,
embedUrl: videoUrl, // should this be different than contentURL
width: '100 px', // height ?
height: '100 px', // width ?
interactionStatistic: [{
'@type': 'InteractionCounter',
interactionType: { '@type': 'http://schema.org/WatchAction' },
userInteractionCount: views
}, {
'@type': 'InteractionCounter',
interactionType: { '@type': 'http://schema.org/LikeAction' },
userInteractionCount: loves
}],
creator: {
'@type': 'Person',
name: authorName,
url: profileLink,
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
// 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,
// },
// },
// ],
};
if (json.publisher) {
json.publisher = {
publisher: {
'@type': 'Organization',
name: publisher.name,
logo: _extends({
'@type': 'ImageObject'
}, publisher.logo)
}
};
}
return json;
}

2

package.json
{
"name": "trell-story-json-to-amp",
"version": "2.0.4",
"version": "2.0.5",
"description": "Convert story JSON to STAMP HTML.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc