Remove duplicate code
This commit is contained in:
parent
e2be492667
commit
46143b832f
|
@ -21,44 +21,33 @@ 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}>
|
const posts = this.props.posts.sort((a, b) => {
|
||||||
<Header header={'Blog'} role="heading" aria-level="2"/>
|
return new Date(b.published) - new Date(a.published)
|
||||||
<SearchBox searchString={this.props.searchString}
|
})
|
||||||
expanded={this.props.expanded}
|
|
||||||
handleChange={this.props.handleChange}
|
if (posts.length < 1) {
|
||||||
handleFocus={this.props.handleFocus}
|
postsHTML = (
|
||||||
handleBlur={this.props.handleBlur}
|
<div>
|
||||||
handleSearch={this.props.handleSearch} />
|
<span>No posts found</span>
|
||||||
</div>
|
</div>
|
||||||
<Spinner />
|
)
|
||||||
</div>
|
} else {
|
||||||
)
|
postsHTML = posts.map((post) =>
|
||||||
}
|
<div key={post.title} className={styles.postListItem} role="listitem">
|
||||||
|
<div className={styles.postHeader} >
|
||||||
const posts = this.props.posts.sort((a, b) => {
|
<a href={post.link} className={styles.postTitle}>{post.title}</a>
|
||||||
return new Date(b.published) - new Date(a.published)
|
<span className={styles.postDate}>{post.published}</span>
|
||||||
})
|
</div>
|
||||||
let postsHTML = posts.map((post) =>
|
<div dangerouslySetInnerHTML={{ __html: md.render(post.summary) }}>
|
||||||
<div key={post.title} className={styles.postListItem} role="listitem">
|
</div>
|
||||||
<div className={styles.postHeader} >
|
</div>
|
||||||
<a href={post.link} className={styles.postTitle}>{post.title}</a>
|
)
|
||||||
<span className={styles.postDate}>{post.published}</span>
|
}
|
||||||
</div>
|
|
||||||
<div dangerouslySetInnerHTML={{ __html: md.render(post.summary) }}>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
|
|
||||||
if (postsHTML.length < 1) {
|
|
||||||
postsHTML = (
|
|
||||||
<div>
|
|
||||||
<span>No posts found</span>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue