Skip to content

Instantly share code, notes, and snippets.

@matlc
Created July 20, 2019 21:40
Show Gist options
  • Save matlc/207c7224f5287f3ccd101b051e2849b7 to your computer and use it in GitHub Desktop.
Save matlc/207c7224f5287f3ccd101b051e2849b7 to your computer and use it in GitHub Desktop.
An example GatsbyJS template for a blog post page
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