Created
August 14, 2020 11:04
-
-
Save isNan909/75e15a4329704d659e31974240112103 to your computer and use it in GitHub Desktop.
Creating template with the contentful data
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 { Link, graphql } from "gatsby" | |
| import Layout from "../components/layout" | |
| import SEO from "../components/seo" | |
| const SitePosts = ({ data }) => { | |
| const { heading, subheading, description, image } = data.contentfulSitePost | |
| return ( | |
| <Layout> | |
| <SEO title={heading} /> | |
| <div className="ourpost"> | |
| <h1>{heading}</h1> | |
| <img alt={title} src={image.file.url} /> | |
| <h3>{subheading}</h3> | |
| <p>{description.content.content.value}</p> | |
| <Link to="/siteposts">View more posts</Link> | |
| <Link to="/">Back to Home</Link> | |
| </div> | |
| </Layout> | |
| ) | |
| } | |
| export default SitePosts | |
| export const pageQuery = graphql` | |
| query($slug: String!) { | |
| contentfulSitePost(slug: { eq: $slug }) { | |
| heading | |
| subheading | |
| slug | |
| description { | |
| content { | |
| content { | |
| value | |
| } | |
| } | |
| } | |
| image { | |
| file { | |
| url | |
| } | |
| } | |
| } | |
| } | |
| ` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment