-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblog-post.js
89 lines (81 loc) · 1.9 KB
/
blog-post.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
import React from "react"
import { graphql } from "gatsby"
import styled from "@emotion/styled"
import Layout from "../components/layout"
import SEO from "../components/seo"
const Content = styled.div`
margin: 0 auto;
max-width: 860px;
padding: 1.45rem 1.0875rem;
`
const MarkedHeader = styled.h1`
display: inline;
border-radius: 1em 0 1em 0;
background-image: linear-gradient(
-100deg,
rgba(255, 250, 150, 0.15),
rgba(255, 250, 150, 0.8) 100%,
rgba(255, 250, 150, 0.25)
);
`
const HeaderDate = styled.h3`
margin-top: 10px;
color: #606060;
`
// STYLE THE TAGS INSIDE THE MARKDOWN HERE
const MarkdownContent = styled.div`
a {
text-decoration: none;
position: relative;
background-image: linear-gradient(
rgba(255, 250, 150, 0.8),
rgba(255, 250, 150, 0.8)
);
background-repeat: no-repeat;
background-size: 100% 0.2em;
background-position: 0 88%;
transition: background-size 0.25s ease-in;
&:hover {
background-size: 100% 88%;
}
}
a > code:hover {
text-decoration: underline;
}
`
export default ({ data }) => {
const post = data.markdownRemark
return (
<Layout>
<SEO
title={post.frontmatter.title}
description={post.frontmatter.description || post.excerpt}
/>
<Content>
<MarkedHeader>{post.frontmatter.title}</MarkedHeader>
<HeaderDate>
{post.frontmatter.date} - {post.fields.readingTime.text}
</HeaderDate>
<MarkdownContent dangerouslySetInnerHTML={{ __html: post.html }} />
</Content>
</Layout>
)
}
export const pageQuery = graphql`
query($path: String!) {
markdownRemark(frontmatter: { path: { eq: $path } }) {
html
excerpt(pruneLength: 160)
frontmatter {
date(formatString: "DD MMMM, YYYY")
path
title
}
fields {
readingTime {
text
}
}
}
}
`