Created
January 12, 2021 08:15
-
-
Save michaelhayman/6a276125a58d818bd6c1b0428a23bec8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module.exports = { | |
plugins: [ | |
{ | |
resolve: `gatsby-source-graphql`, | |
options: { | |
typeName: `GraphCMS`, | |
fieldName: `gcms`, | |
url: `https://api-eu-central-1.graphcms.com/v2/ckjp80jbpftcp01z10zldgn49/master` | |
} | |
} | |
] | |
} |
This file contains hidden or 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 from 'react' | |
import { graphql, useStaticQuery, Link } from 'gatsby' | |
const postQuery = graphql` | |
{ | |
gcms { | |
posts { | |
id | |
title | |
slug | |
excerpt | |
author { | |
name | |
} | |
} | |
} | |
} | |
` | |
const Indexpost = () => { | |
const data = useStaticQuery(postQuery) | |
const { | |
gcms: { | |
posts | |
} | |
} = data | |
console.log('posts', data, posts) | |
return ( | |
<div className="posts"> | |
{posts.map(({ slug, ...post }) => | |
<div key={slug}> | |
<Link to={`/posts/${slug}`}>{post.title}</Link> | |
<div>{post.excerpt}</div> | |
<div>{post.name}</div> | |
</div> | |
)} | |
</div> | |
) | |
} | |
export default Indexpost |
This file contains hidden or 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
module.exports = { | |
plugins: [ | |
{ | |
resolve: `gatsby-source-graphql`, | |
options: { | |
typeName: `GraphCMS`, | |
fieldName: `gcms`, | |
url: `redacated` | |
} | |
} | |
] | |
} |
This file contains hidden or 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 from 'react' | |
import { graphql, useStaticQuery, Link } from 'gatsby' | |
const postQuery = graphql` | |
{ | |
gcms { | |
posts { | |
id | |
title | |
slug | |
excerpt | |
author { | |
name | |
} | |
} | |
} | |
} | |
` | |
const Indexpost = () => { | |
const data = useStaticQuery(postQuery) | |
const { | |
gcms: { | |
posts | |
} | |
} = data | |
console.log('posts', data, posts) | |
return ( | |
<div className="posts"> | |
{posts.map(({ slug, ...post }) => | |
<div key={slug}> | |
<Link to={`/posts/${slug}`}>{post.title}</Link> | |
<div>{post.excerpt}</div> | |
<div>{post.name}</div> | |
</div> | |
)} | |
</div> | |
) | |
} | |
export default Indexpost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment