Some formatting
This commit is contained in:
parent
9c3037fb7e
commit
180a0a0cfb
1 changed files with 41 additions and 41 deletions
|
@ -7,52 +7,52 @@ import { Link } from 'react-router-dom';
|
|||
|
||||
|
||||
class PostList extends React.Component {
|
||||
componentDidMount() {
|
||||
this.props.fetchPosts();
|
||||
}
|
||||
renderList() {
|
||||
const {posts} = this.props
|
||||
const postKeys = Object.keys(posts.entities)
|
||||
return postKeys.map(id => {
|
||||
const post = posts.entities[id]
|
||||
return (
|
||||
<div className="item" key={post.id}>
|
||||
<div className="content">
|
||||
<div className="description">
|
||||
<h1><b><u><Link to={"/posts/" + post.slug}>{post.title}</Link></u></b></h1>
|
||||
<h3><b>By <Link to={"/users/"+ post.author}>{post.author}</Link></b></h3>
|
||||
<h4>Posted {post.time_published}</h4>
|
||||
<div className="markdown-body">
|
||||
<ReactMarkdown source={post.content} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}).reverse();
|
||||
}
|
||||
|
||||
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<h1>Blog Posts</h1>
|
||||
<div className="ui relaxed divided list">
|
||||
{this.renderList()}
|
||||
</div>
|
||||
componentDidMount() {
|
||||
this.props.fetchPosts();
|
||||
}
|
||||
renderList() {
|
||||
const {posts} = this.props
|
||||
const postKeys = Object.keys(posts.entities)
|
||||
return postKeys.map(id => {
|
||||
const post = posts.entities[id]
|
||||
return (
|
||||
<div className="item" key={post.id}>
|
||||
<div className="content">
|
||||
<div className="description">
|
||||
<h1><b><u><Link to={"/posts/" + post.slug}>{post.title}</Link></u></b></h1>
|
||||
<h3><b>By <Link to={"/users/"+ post.author}>{post.author}</Link></b></h3>
|
||||
<h4>Posted {post.time_published}</h4>
|
||||
<div className="markdown-body">
|
||||
<ReactMarkdown source={post.content} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}).reverse();
|
||||
}
|
||||
|
||||
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<h1>Blog Posts</h1>
|
||||
<div className="ui relaxed divided list">
|
||||
{this.renderList()}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
posts: state.posts,
|
||||
slug: state.slug
|
||||
};
|
||||
return {
|
||||
posts: state.posts,
|
||||
slug: state.slug
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
{ fetchPosts }
|
||||
mapStateToProps,
|
||||
{ fetchPosts }
|
||||
)(PostList);
|
||||
|
|
Reference in a new issue