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