-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblog.js
105 lines (97 loc) · 2.26 KB
/
blog.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
import React from "react"
import { Link, graphql } from "gatsby"
import { css } from "@emotion/core"
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 ArticleDate = styled.h5`
display: inline;
color: #606060;
`
const MarkerHeader = styled.h3`
display: inline;
border-radius: 0.5em 0 1em 0;
background-image: linear-gradient(
-100deg,
rgba(255, 250, 150, 0.15),
rgba(155 200 255 / 80%) 100%,
rgba(255, 250, 150, 0.25)
);
`
const ReadingTime = styled.h5`
display: inline;
color: #606060;
`
const IndexPage = ({ data }) => {
return (
<Layout>
<SEO title="Blog" />
<Content>
<h1>Blog</h1>
{data.allMarkdownRemark.edges
.filter(({ node }) => {
const rawDate = node.frontmatter.rawDate
const date = new Date(rawDate)
return date < new Date()
})
.map(({ node }) => (
<div key={node.id}>
<Link
to={node.frontmatter.path}
css={css`
text-decoration: none;
color: inherit;
`}
>
<MarkerHeader>{node.frontmatter.title}</MarkerHeader>
</Link>
<div>
<ArticleDate>{node.frontmatter.date}</ArticleDate>
<ReadingTime> - {node.fields.readingTime.text}</ReadingTime>
</div>
<p>{node.excerpt}</p>
</div>
))}
</Content>
</Layout>
)
}
export default IndexPage
export const query = graphql`
query {
site {
siteMetadata {
title
}
}
allMarkdownRemark(
sort: { fields: [frontmatter___date], order: DESC }
filter: { frontmatter: { draft: { eq: false } } }
) {
totalCount
edges {
node {
id
frontmatter {
title
date(formatString: "DD MMMM, YYYY")
rawDate: date
path
}
fields {
slug
readingTime {
text
}
}
excerpt
}
}
}
}
`