Last active
November 11, 2017 16:51
-
-
Save ryancoughlin/406774d36906b91ec2a9d97d6b45fc6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react" | |
import PropTypes from "prop-types" | |
import Link from "gatsby-link" | |
class Home extends Component { | |
render() { | |
const data = this.props.data | |
console.log(data) | |
return ( | |
<div> | |
<h1>Posts</h1> | |
{data.allWordpressPost.edges.map(({ node }) => ( | |
<div key={node.slug}> | |
<Link to={node.slug} css={{ textDecoration: `none` }}> | |
<h3>{node.title}</h3> | |
</Link> | |
<div dangerouslySetInnerHTML={{ __html: node.excerpt }} /> | |
</div> | |
))} | |
</div> | |
) | |
} | |
} | |
export default Home | |
export const postQuery = graphql` | |
query getPostQuery { | |
allWordpressPost(sort: { fields: [date] }) { | |
edges { | |
node { | |
title | |
excerpt | |
slug | |
} | |
} | |
} | |
} | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment