Skip to content

Commit db4fbcf

Browse files
committed
created blog template
1 parent 6727af2 commit db4fbcf

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
path: "/hello-world"
3+
date: "2017-09-02T18:12:33.962Z"
4+
title: "Hello World"
5+
---
6+
7+
This is my first blog post!

src/templates/blog-post.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import Helmet from 'react-helmet';
3+
4+
export default function Template({ data }) {
5+
const { markdownRemark: post } = data; // data.markdownRemark holds our post data
6+
return (
7+
<div className="blog-post-container">
8+
<Helmet title={`Blog - ${post.frontmatter.title}`} />
9+
<div className="blog-post">
10+
<h1>{post.frontmatter.title}</h1>
11+
<div className="blog-post-content" dangerouslySetInnerHTML={{ __html: post.html }} />
12+
</div>
13+
</div>
14+
);
15+
}
16+
17+
export const pageQuery = graphql`
18+
query BlogPostByPath($path: String!) {
19+
markdownRemark(frontmatter: { path: { eq: $path } }) {
20+
html
21+
frontmatter {
22+
path
23+
date(formatString: "MMMM DD, YYYY")
24+
title
25+
}
26+
}
27+
}
28+
`;

0 commit comments

Comments
 (0)