Socket
Socket
Sign inDemoInstall

article-json-to-fbia

Package Overview
Dependencies
24
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

7

dist/format-items.js

@@ -30,2 +30,9 @@ 'use strict';

},
spotify: function spotify() {
return {
figureProps: {
'class': 'op-interactive'
}
};
},
instagram: function instagram() {

@@ -32,0 +39,0 @@ return {

52

dist/index.js

@@ -21,17 +21,27 @@ 'use strict';

function renderSpotify(_ref) {
var url = _ref.url;
var height = _ref.height;
var w = 300;
// Small and large sizes are supported only
var h = height <= 80 ? 80 : 380;
return (0, _deku.element)('iframe', { src: url, width: w, height: h, frameborder: '0' });
} /* eslint-disable deku/no-unknown-property */
var embeds = {
youtube: function youtube(_ref) {
var youtubeId = _ref.youtubeId;
youtube: function youtube(_ref2) {
var youtubeId = _ref2.youtubeId;
return (0, _embeds.render)({ type: 'youtube', youtubeId: youtubeId });
},
image: function image(_ref2) {
var src = _ref2.src;
image: function image(_ref3) {
var src = _ref3.src;
return (0, _embeds.render)({ type: 'image', src: src });
},
twitter: function twitter(_ref3) {
var text = _ref3.text;
var url = _ref3.url;
var date = _ref3.date;
var user = _ref3.user;
var id = _ref3.id;
twitter: function twitter(_ref4) {
var text = _ref4.text;
var url = _ref4.url;
var date = _ref4.date;
var user = _ref4.user;
var id = _ref4.id;
return (0, _deku.element)(

@@ -47,4 +57,4 @@ 'iframe',

},
vine: function vine(_ref4) {
var url = _ref4.url;
vine: function vine(_ref5) {
var url = _ref5.url;
return (0, _embeds.render)({ type: 'vine', url: url, size: 480 });

@@ -54,16 +64,18 @@ },

// the embeds module adds the instagram embed code, for FBIA the iframe is enough
instagram: function instagram(_ref5) {
var url = _ref5.url;
instagram: function instagram(_ref6) {
var url = _ref6.url;
return (0, _deku.element)('iframe', { src: (0, _urlJoin2.default)(url, 'embed') });
},
spotify: renderSpotify,
// custom needs to be last
custom: function custom(_ref6) {
var src = _ref6.src;
var width = _ref6.width;
var height = _ref6.height;
var secure = _ref6.secure;
custom: function custom(_ref7) {
var src = _ref7.src;
var width = _ref7.width;
var height = _ref7.height;
var secure = _ref7.secure;
return secure && (0, _embeds.render)({ type: 'custom', src: src, width: width, height: height }) || '';
}
}; /* eslint-disable deku/no-unknown-property */
};

@@ -70,0 +82,0 @@ var customCaption = function customCaption(text) {

@@ -16,2 +16,7 @@ import assign from 'object-assign';

}),
spotify: () => ({
figureProps: {
'class': 'op-interactive'
}
}),
instagram: () => ({

@@ -18,0 +23,0 @@ figureProps: {

@@ -9,2 +9,9 @@ /* eslint-disable deku/no-unknown-property */

function renderSpotify ({url, height}) {
const w = 300;
// Small and large sizes are supported only
const h = height <= 80 ? 80 : 380;
return <iframe src={url} width={w} height={h} frameborder='0'/>;
}
const embeds = {

@@ -25,2 +32,4 @@ youtube: ({youtubeId}) => render({type: 'youtube', youtubeId}),

spotify: renderSpotify,
// custom needs to be last

@@ -27,0 +36,0 @@ custom: ({src, width, height, secure}) => secure && render({type: 'custom', src, width, height}) || ''

{
"name": "article-json-to-fbia",
"version": "1.0.0",
"version": "1.1.0",
"description": "transform article-json to Facebook's instant-articles",

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

@@ -198,2 +198,42 @@ import test from 'ava';

test('spotify small', t => {
const input = [{
type: 'embed',
embedType: 'spotify',
url: 'https://embed.spotify.com/?uri=spotify:user:spotify:playlist:3rgsDhGHZxZ9sB9DQWQfuf',
spotifyUri: 'spotify:user:spotify:playlist:3rgsDhGHZxZ9sB9DQWQfuf',
width: 400,
height: 80
}];
const actual = toFbia(input);
const expected = tsml`
<article>
<figure class="op-interactive">
<iframe src="https://embed.spotify.com/?uri=spotify:user:spotify:playlist:3rgsDhGHZxZ9sB9DQWQfuf" width="300" height="80" frameborder="0"></iframe>
</figure>
</article>
`;
t.is(actual, expected);
});
test('spotify large', t => {
const input = [{
type: 'embed',
embedType: 'spotify',
url: 'https://embed.spotify.com/?uri=spotify:user:spotify:playlist:3rgsDhGHZxZ9sB9DQWQfuf',
spotifyUri: 'spotify:user:spotify:playlist:3rgsDhGHZxZ9sB9DQWQfuf',
width: 400,
height: 300
}];
const actual = toFbia(input);
const expected = tsml`
<article>
<figure class="op-interactive">
<iframe src="https://embed.spotify.com/?uri=spotify:user:spotify:playlist:3rgsDhGHZxZ9sB9DQWQfuf" width="300" height="380" frameborder="0"></iframe>
</figure>
</article>
`;
t.is(actual, expected);
});
test('instagram', t => {

@@ -200,0 +240,0 @@ const input = [{

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc