Created
July 20, 2019 21:40
-
-
Save matlc/207c7224f5287f3ccd101b051e2849b7 to your computer and use it in GitHub Desktop.
An example GatsbyJS template for a blog post page
This file contains 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 } from "gatsby" | |
import Layout from "../components/layout" | |
const BlogPost = ({data: {post}}) => ( | |
<Layout> | |
<h1>{post.title}</h1> | |
<h4>By <Link to={`/author/${post.author.slug}`}>{post.author.name}</Link></h4> | |
<p>{post.publishDate}</p> | |
<hr /> | |
<p>{post.content}</p> | |
<hr /> | |
<p style={{fontStyle:"italic"}}>Tags: {post.tags.join(', ')}</p> | |
</Layout> | |
) | |
export const query = graphql` | |
query ($id: String!) { | |
post: postsJson(id: {eq: $id}) { | |
title | |
slug | |
content | |
publishDate(formatString: "MMMM DD, YYYY") | |
tags | |
author { | |
slug | |
name | |
biography | |
} | |
} | |
} | |
` | |
export default BlogPost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment