Skip to content

Instantly share code, notes, and snippets.

@aanoaa
Last active December 11, 2019 05:25
Show Gist options
  • Save aanoaa/6370d9755d245fe8dc8a74c979acd850 to your computer and use it in GitHub Desktop.
Save aanoaa/6370d9755d245fe8dc8a74c979acd850 to your computer and use it in GitHub Desktop.
import React from "react"
import { graphql } from "gatsby"
import Layout from "../components/layout"
import SEO from "../components/seo"
const Product = ({ data }) => (
<Layout>
<SEO title={data.wordpressWpProduct.title} />
<h1>{data.wordpressWpProduct.edges[0].title}</h1>
<p>{data.wordpressWpProduct.edges[0].excerpt}</p>
</Layout>
)
export default Product
export const postQuery = graphql`
query($id: String!) {
allWordpressWpProduct(filter: { id: { eq: $id } }) {
edges {
node {
id
title
excerpt
date(formatString: "YYYY-MM-DD")
link
slug
}
}
}
}
`
@pys99pys
Copy link

pys99pys commented Dec 11, 2019

const Product = ({ data }) => {
  const p = data.wordpressWpProduct;
  const first = p.edges[0];
  return (
    <Layout>
      <SEO title={p.title} />
      <h1>{first.title}</h1>
      <p>{first.excerpt}</p>
    </Layout>
  );
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment