Remove duplicate code
This commit is contained in:
parent
e2be492667
commit
46143b832f
|
@ -21,28 +21,23 @@ export default class Blog extends Component {
|
|||
|
||||
render () {
|
||||
const md = MarkdownIt()
|
||||
let postsHTML
|
||||
|
||||
if (this.props.isLoading) {
|
||||
return (
|
||||
<div className={`${contentStyle.content}`} id="blog" role="region" aria-label="Blog posts">
|
||||
<div className={styles.headerContainer}>
|
||||
<Header header={'Blog'} role="heading" aria-level="2"/>
|
||||
<SearchBox searchString={this.props.searchString}
|
||||
expanded={this.props.expanded}
|
||||
handleChange={this.props.handleChange}
|
||||
handleFocus={this.props.handleFocus}
|
||||
handleBlur={this.props.handleBlur}
|
||||
handleSearch={this.props.handleSearch} />
|
||||
</div>
|
||||
<Spinner />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
postsHTML = <Spinner />
|
||||
} else {
|
||||
const posts = this.props.posts.sort((a, b) => {
|
||||
return new Date(b.published) - new Date(a.published)
|
||||
})
|
||||
let postsHTML = posts.map((post) =>
|
||||
|
||||
if (posts.length < 1) {
|
||||
postsHTML = (
|
||||
<div>
|
||||
<span>No posts found</span>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
postsHTML = posts.map((post) =>
|
||||
<div key={post.title} className={styles.postListItem} role="listitem">
|
||||
<div className={styles.postHeader} >
|
||||
<a href={post.link} className={styles.postTitle}>{post.title}</a>
|
||||
|
@ -52,13 +47,7 @@ export default class Blog extends Component {
|
|||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
if (postsHTML.length < 1) {
|
||||
postsHTML = (
|
||||
<div>
|
||||
<span>No posts found</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
Loading…
Reference in New Issue