-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpost-template.js
115 lines (104 loc) · 2.27 KB
/
post-template.js
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import React from 'react'
import Layout from '../components/Layout'
import Hero from '../components/Hero'
import styled from 'styled-components'
import Image from 'gatsby-image'
import Banner from '../components/Banner'
import { graphql } from 'gatsby'
import { MDXRenderer } from 'gatsby-plugin-mdx'
import Seo from '../components/Seo'
export const query = graphql`
query GetSinglePost($slug: String) {
mdx(frontmatter: { slug: { eq: $slug } }) {
frontmatter {
title
category
date(formatString: "MMMM Do, YYYY")
readTime
slug
image {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
}
}
}
body
}
}
`
const PostTemplate = ({ data }) => {
const {
mdx: {
frontmatter: { title, category, date, image },
body,
},
} = data
return (
<Layout>
<Seo title={`${title.toUpperCase()} Post Page`} />
<Hero />
<Wrapper>
<article>
<Image fluid={image.childImageSharp.fluid} />
<div className="post-info">
<span>{category}</span>
<h2>{title}</h2>
<p>{date}</p>
<div className="underline" />
</div>
<MDXRenderer>{body}</MDXRenderer>
</article>
<article>
<Banner />
</article>
</Wrapper>
</Layout>
)
}
const Wrapper = styled.section`
width: 85vw;
max-width: 1100px;
margin: 0 auto;
margin-bottom: 4rem;
.post-info {
margin: 2rem 0 4rem 0;
text-align: center;
span {
background: var(--clr-primary-5);
color: var(--clr-white);
border-radius: var(--radius);
padding: 0.25rem 0.5rem;
text-transform: uppercase;
letter-spacing: var(--spacing);
}
h2 {
margin: 1.25rem 0;
font-weight: 400;
}
p {
color: var(--clr-grey-5);
}
.underline {
width: 5rem;
height: 1px;
background: var(--clr-grey-9);
margin: 0 auto;
margin-bottom: 1rem;
}
}
@media (min-width: 992px) {
& {
width: 92vw;
}
}
@media (min-width: 1170px) {
& {
display: grid;
grid-template-columns: 1fr 200px;
column-gap: 4rem;
}
}
`
export default PostTemplate