Fetch posts frm wp on blog page

This commit is contained in:
Moris Zen
2018-07-06 09:35:17 +02:00
parent b3a9a16a59
commit 7867ae3b09
2 changed files with 22 additions and 16 deletions

View File

@@ -1,6 +1,8 @@
import React, { Component } from 'react'
import Link from 'gatsby-link'
import Card from '../components/Card'
class Blog extends Component {
render() {
const data = this.props.data
@@ -8,13 +10,13 @@ class Blog extends Component {
<div>
<h1>Blog Posts</h1>
{data.allWordpressPost.edges.map(({ node }) => (
<article key={node.slug}>
<Link to={`post/${node.slug}`}>
<h3>{node.title}</h3>
</Link>
{node.date}
<p dangerouslySetInnerHTML={{ __html: node.excerpt }} />
</article>
<Card
url={`blog/${node.slug}`}
title={node.title}
postId={node.slug}
date={node.date}
excerpt={node.excerpt}
/>
))}
</div>
)