-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathBlog.jsx
More file actions
98 lines (95 loc) · 2.36 KB
/
Blog.jsx
File metadata and controls
98 lines (95 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import React from "react";
import { graphql } from "gatsby";
import { GatsbyImage } from "gatsby-plugin-image";
import moment from "moment";
import Layout from "../layout";
import SocialLinks from "../components/SocialLinks/SocialLinks";
import SEO from "../components/SEO/SEO";
import config from "../../data/SiteConfig";
export default class Blog extends React.Component {
render() {
const { data, pageContext } = this.props;
const { slug } = pageContext;
const postNode = data.markdownRemark;
const post = postNode.frontmatter;
if (!post.id) {
post.id = slug;
}
if (!post.category_id) {
post.category_id = config.postDefaultCategoryID;
}
const { date } = postNode.fields;
return (
<Layout title={post.title}>
<style jsx>{`
.gatsby-highlight {
font-size: 15px;
color: red;
}
`}</style>
<div>
<div>
<div className="title">
<h6>
{`Posted by ${post.author} on `}
<span>{moment(date).format("MMMM DD, YYYY")}</span>
</h6>
</div>
<br />
<GatsbyImage
className="post-cover"
image={post.cover.childImageSharp.gatsbyImageData}
/>
<br />
<hr />
<div
className="post-content"
dangerouslySetInnerHTML={{ __html: postNode.html }}
/>
<hr />
<div className="post-meta">
<SocialLinks
title={post.title}
excerpt={post.excerpt}
path={`/blog${slug}`}
/>
</div>
</div>
</div>
</Layout>
);
}
}
/* eslint no-undef: "off" */
export const pageQuery = graphql`
query BlogPostBySlug($slug: String!) {
markdownRemark(fields: { slug: { eq: $slug } }) {
html
timeToRead
excerpt
frontmatter {
title
tags
author
cover {
publicURL
childImageSharp {
gatsbyImageData
}
}
}
fields {
slug
date
}
}
}
`;
export function Head({ data, pageContext }) {
return (
<SEO
pathname={pageContext.slug}
title={`${data.markdownRemark.frontmatter.title} | ${config.siteTitle}`}
/>
);
}