Created
January 5, 2018 15:10
-
-
Save fpersico/695e6a1e6d535ae5b4a04259e946f47c to your computer and use it in GitHub Desktop.
ArticleFull
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple component that render an Article in Full-Mode | |
import React, { Component } from 'react'; | |
import moment from 'moment'; | |
import ImageDerivative from './ImageDerivative'; | |
import './Article.css'; | |
import './ArticleFull.css'; | |
class ArticleFull extends Component { | |
createBodyMarkup(markup) { | |
return { __html: markup }; | |
} | |
render() { | |
const { article } = this.props; | |
const momentDate = moment(article.created * 1000).format('DD MMM YYYY'); | |
return ( | |
<div className="article article--full"> | |
<h2 className="article__title">{article.title}</h2> | |
<div className="article__date">{momentDate}</div> | |
<div className="article__image"> | |
<ImageDerivative image={article.fieldImage} derivative="large" /> | |
</div> | |
<div | |
className="article__body" | |
dangerouslySetInnerHTML={this.createBodyMarkup(article.body.value)} | |
/> | |
</div> | |
); | |
} | |
} | |
export default ArticleFull; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment