article-json-to-fbia
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -58,2 +58,9 @@ 'use strict'; | ||
}; | ||
}, | ||
tumblr: function tumblr() { | ||
return { | ||
figureProps: { | ||
'class': 'op-interactive' | ||
} | ||
}; | ||
} | ||
@@ -60,0 +67,0 @@ }; |
@@ -76,8 +76,20 @@ 'use strict'; | ||
tumblr: function tumblr(_ref7) { | ||
var did = _ref7.did; | ||
var url = _ref7.url; | ||
var text = _ref7.text; | ||
return (0, _magicVirtualElement2.default)( | ||
'iframe', | ||
null, | ||
(0, _embeds.render)({ type: 'tumblr', did: did, url: url, text: text }), | ||
(0, _magicVirtualElement2.default)('script', { async: true, src: 'https://secure.assets.tumblr.com/post.js' }) | ||
); | ||
}, | ||
// custom needs to be last | ||
custom: function custom(_ref7) { | ||
var src = _ref7.src; | ||
var width = _ref7.width; | ||
var height = _ref7.height; | ||
var secure = _ref7.secure; | ||
custom: function custom(_ref8) { | ||
var src = _ref8.src; | ||
var width = _ref8.width; | ||
var height = _ref8.height; | ||
var secure = _ref8.secure; | ||
return secure && (0, _embeds.render)({ type: 'custom', src: src, width: width, height: height }) || ''; | ||
@@ -84,0 +96,0 @@ } |
@@ -36,2 +36,7 @@ import assign from 'object-assign'; | ||
} | ||
}), | ||
tumblr: () => ({ | ||
figureProps: { | ||
'class': 'op-interactive' | ||
} | ||
}) | ||
@@ -38,0 +43,0 @@ }; |
@@ -34,2 +34,9 @@ /* eslint-disable deku/no-unknown-property */ | ||
tumblr: ({did, url, text}) => ( | ||
<iframe> | ||
{render({type: 'tumblr', did, url, text})} | ||
<script async src='https://secure.assets.tumblr.com/post.js'></script> | ||
</iframe> | ||
), | ||
// custom needs to be last | ||
@@ -36,0 +43,0 @@ custom: ({src, width, height, secure}) => secure && render({type: 'custom', src, width, height}) || '' |
{ | ||
"name": "article-json-to-fbia", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "transform article-json to Facebook's instant-articles", | ||
@@ -43,3 +43,3 @@ "main": "dist/index.js", | ||
"deku": "^1.0.0", | ||
"embeds": "^2.5.0", | ||
"embeds": "^2.6.0", | ||
"magic-virtual-element": "^1.0.6", | ||
@@ -46,0 +46,0 @@ "object-assign": "^4.0.1", |
32
test.js
@@ -304,2 +304,34 @@ import test from 'ava'; | ||
test('tumblr embed', t => { | ||
const data = [{ | ||
caption: [], | ||
type: 'embed', | ||
embedType: 'tumblr', | ||
did: '7c08ba46cb75162284770cdee2a59365891a5e18', | ||
url: 'https://embed.tumblr.com/embed/post/8_SX4ALNOf1fYyEcjq78YQ/147291233392', | ||
text: [{ | ||
content: 'http://jencita.tumblr.com/post/147291233392/tswiftdaily-taylor-swift-at-lady-cilento', | ||
href: 'http://jencita.tumblr.com/post/147291233392/tswiftdaily-taylor-swift-at-lady-cilento' | ||
}] | ||
}]; | ||
const actual = toFbia(data); | ||
const expected = tsml` | ||
<article> | ||
<figure class="op-interactive"> | ||
<iframe> | ||
<div class="tumblr-post" data-href="https://embed.tumblr.com/embed/post/8_SX4ALNOf1fYyEcjq78YQ/147291233392" data-did="7c08ba46cb75162284770cdee2a59365891a5e18"> | ||
<a href="http://jencita.tumblr.com/post/147291233392/tswiftdaily-taylor-swift-at-lady-cilento"> | ||
http://jencita.tumblr.com/post/147291233392/tswiftdaily-taylor-swift-at-lady-cilento | ||
</a> | ||
</div> | ||
<script async="true" src="https://secure.assets.tumblr.com/post.js"></script> | ||
</iframe> | ||
</figure> | ||
</article> | ||
`; | ||
t.is(actual, expected); | ||
}); | ||
test('custom secure iframe', t => { | ||
@@ -306,0 +338,0 @@ const data = [{ |
19893
584
Updatedembeds@^2.6.0