Skip to content

Instantly share code, notes, and snippets.

@ryancoughlin
Last active November 11, 2017 16:51
Show Gist options
  • Save ryancoughlin/406774d36906b91ec2a9d97d6b45fc6e to your computer and use it in GitHub Desktop.
Save ryancoughlin/406774d36906b91ec2a9d97d6b45fc6e to your computer and use it in GitHub Desktop.
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