article-json-html-render
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -26,2 +26,3 @@ 'use strict'; | ||
var caption = props.caption; | ||
var figureProps = props.figureProps; | ||
@@ -34,3 +35,3 @@ var embed = embeds[embedType] && embeds[embedType](props); | ||
'figure', | ||
null, | ||
figureProps, | ||
embed, | ||
@@ -37,0 +38,0 @@ captionElm |
@@ -7,3 +7,3 @@ import {element} from 'deku'; | ||
render: ({props}) => { | ||
const {embedType, caption} = props; | ||
const {embedType, caption, figureProps} = props; | ||
const embed = embeds[embedType] && embeds[embedType](props); | ||
@@ -14,3 +14,3 @@ | ||
return <figure>{embed}{captionElm}</figure>; | ||
return <figure {...figureProps}>{embed}{captionElm}</figure>; | ||
} | ||
@@ -17,0 +17,0 @@ }); |
{ | ||
"name": "article-json-html-render", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Base for html-based article-json renderer, such as [article-json-to-amp](https://www.npmjs.com/package/article-json-to-amp)", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
31
test.js
@@ -46,2 +46,33 @@ import test from 'tape'; | ||
test('embed with custom figureProps', t => { | ||
t.plan(2); | ||
const Article = setupArticle({ | ||
embeds: { | ||
twitter: tweet => { | ||
t.equal(tweet.id, 'twitter-id'); | ||
return <span id={tweet.id} />; | ||
} | ||
} | ||
}); | ||
const items = [{ | ||
type: 'embed', | ||
embedType: 'twitter', | ||
id: 'twitter-id', | ||
figureProps: { | ||
foo: 'bar', | ||
hello: 'world' | ||
} | ||
}]; | ||
const expected = string.render( | ||
<article> | ||
<figure foo='bar' hello='world'><span id='twitter-id'/></figure> | ||
</article>); | ||
const actual = string.render(<Article items={items} />); | ||
t.equal(actual, expected); | ||
t.end(); | ||
}); | ||
test('text elements', t => { | ||
@@ -48,0 +79,0 @@ const Article = setupArticle({ embeds: {} }); |
24110
677