Created
January 19, 2019 18:24
-
-
Save haxzie-xx/97b116ba9a8730cfd3dd22899aef1437 to your computer and use it in GitHub Desktop.
Gatsby blog post template
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 } from 'gatsby' | |
| import Layout from '../components/layout' | |
| const BlogPostTemplate = ({ data }) => { | |
| // extract the contents from data | |
| const { markdownRemark } = data; | |
| const { frontmatter, html } = markdownRemark; | |
| // return the component layout | |
| return ( | |
| <Layout> | |
| <h1>{ frontmatter.title }</h1> | |
| <h3> { frontmatter.author } | { frontmatter.date } </h3> | |
| <div dangerouslySetInnerHTML={{ __html: html }}></div> | |
| </Layout> | |
| ); | |
| } | |
| export default BlogPostTemplate; | |
| export const postDataQuery = graphql` | |
| query postDataQuery($path: String!) { | |
| markdownRemark(frontmatter: { slug: { eq: $path } }) { | |
| html | |
| frontmatter { | |
| title | |
| author | |
| date | |
| } | |
| } | |
| } | |
| ` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment