diff --git a/src/components/Blog.js b/src/components/Blog.js index 0286a34..b663bff 100644 --- a/src/components/Blog.js +++ b/src/components/Blog.js @@ -20,7 +20,10 @@ export default class Blog extends Component { ) } - let posts = this.props.posts.map((post) => + let posts = this.props.posts.sort((a, b) => { + return a.data - b.date + }) + let postsHTML = posts.map((post) => {post.published} @@ -38,7 +41,7 @@ export default class Blog extends Component {
- {posts} + {postsHTML}
diff --git a/src/components/Post.js b/src/components/Post.js index fd146bc..b2a28b2 100644 --- a/src/components/Post.js +++ b/src/components/Post.js @@ -5,6 +5,7 @@ import '../static/stylesheets/globals.scss' import contentStyle from '../static/stylesheets/content.scss' import styles from './Post.scss' import MarkdownIt from 'markdown-it' +import fm from 'front-matter' export default class Post extends Component { static propTypes = { @@ -14,7 +15,10 @@ export default class Post extends Component { render () { const md = MarkdownIt() - const result = md.render(this.props.post) + const content = fm(this.props.post) + const title = content.attributes.title + const date = content.attributes.date + const body = md.render(content.body) if (this.props.isLoading) { return ( @@ -28,12 +32,12 @@ export default class Post extends Component {
-
+
-

{this.props.post.published}

+

{date}

-
+