import PropTypes from 'prop-types' import React, { Component } from 'react' import { Spinner, Header, SearchBox } from '.' import '../stylesheets/globals.scss' import MarkdownIt from 'markdown-it' import styles from './Blog.scss' import contentStyle from '../stylesheets/content.scss' export default class Blog extends Component { static propTypes = { isLoading: PropTypes.bool.isRequired, posts: PropTypes.arrayOf(PropTypes.object).isRequired, searchString: PropTypes.string, expanded: PropTypes.bool.isRequired, handleChange: PropTypes.func.isRequired, handleFocus: PropTypes.func.isRequired, handleBlur: PropTypes.func.isRequired, handleEnter: PropTypes.func.isRequired, handleSearch: PropTypes.func.isRequired } render () { const md = MarkdownIt() let postsHTML if (this.props.isLoading) { postsHTML = } else { const posts = this.props.posts.sort((a, b) => { return new Date(b.published) - new Date(a.published) }) if (posts.length < 1) { postsHTML = (
No posts found
) } else { postsHTML = posts.map((post) =>
{post.title} {post.published}
) } } return (
{postsHTML}
) } };