Update JSONFeedReader to use latest live schema
parent
3a37bfc409
commit
edb14f4ff5
|
@ -5,25 +5,53 @@ import moment from 'moment'
|
|||
const JSONFeedReader = ({data}) =>
|
||||
data
|
||||
? <div className="newsfeed">
|
||||
{data.items.map(({date_published, title, content_html}, i) =>
|
||||
<div key={i} className="newsfeed--post">
|
||||
<div className="newsfeed--date">
|
||||
{`${moment(date_published).format('MMM DD')}`}
|
||||
{data.items.map(
|
||||
({
|
||||
id,
|
||||
date_published,
|
||||
url,
|
||||
title,
|
||||
author: {name},
|
||||
image,
|
||||
content_text: contentText,
|
||||
}) =>
|
||||
<div key={id} className="newsfeed--post">
|
||||
<div className="newsfeed--date">
|
||||
{`${moment(date_published).format('MMM DD')}`}
|
||||
</div>
|
||||
<div className="newsfeed--post-title">
|
||||
<a href={url} target="_blank">
|
||||
<h6>{title}</h6>
|
||||
</a>
|
||||
<span>by {name}</span>
|
||||
</div>
|
||||
<div className="newsfeed--content">
|
||||
{image ? <img src={image} /> : null}
|
||||
<p>{contentText}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="newsfeed--post-title">{title}</div>
|
||||
<div className="newsfeed--content">
|
||||
<div dangerouslySetInnerHTML={{__html: content_html}} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
: null
|
||||
|
||||
const {shape} = PropTypes
|
||||
const {arrayOf, instanceOf, shape, string} = PropTypes
|
||||
|
||||
// TODO: define JSONFeed schema
|
||||
JSONFeedReader.propTypes = {
|
||||
data: shape().isRequired,
|
||||
data: shape({
|
||||
items: arrayOf(
|
||||
shape({
|
||||
author: shape({
|
||||
name: string.isRequired,
|
||||
}).isRequired,
|
||||
content_text: string.isRequired,
|
||||
date_published: instanceOf(Date),
|
||||
id: string.isRequired,
|
||||
image: string,
|
||||
title: string.isRequired,
|
||||
url: string.isRequired,
|
||||
})
|
||||
),
|
||||
}).isRequired,
|
||||
}
|
||||
|
||||
export default JSONFeedReader
|
||||
|
|
Loading…
Reference in New Issue