Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (70 sloc) 1.77 KB
import React from "react"
import { useStaticQuery, graphql } from "gatsby"
import Layout from "../components/layout"
import SEO from "../components/seo"
import {
Year,
SubTitle,
PostItemContainer,
PostTitle,
PostDate,
PostLink,
} from "../components/styles/LayoutStyles"
const Blog = () => {
const query = useStaticQuery(graphql`
query {
allMdx(
filter: { fileAbsolutePath: { regex: "/(posts)/" } }
sort: { fields: frontmatter___date, order: DESC }
) {
group(field: fields___dateYear) {
fieldValue
nodes {
frontmatter {
title
date(formatString: "MMM DD")
}
id
fields {
pageUrl
dateYear
}
}
}
}
}
`)
const data = query.allMdx.group
return (
<Layout>
<SEO title="Blog" />
<h1>Blog</h1>
<SubTitle>Updated seldomly.</SubTitle>
<ul>
{data
.slice(0)
.reverse()
.map(blogPost => {
return (
<React.Fragment key={blogPost.fieldValue}>
<Year>{blogPost.fieldValue}</Year>
{blogPost.nodes.map(post => {
return (
<PostItemContainer key={post.id}>
<PostTitle>
<PostLink to={`/blog/${post.fields.pageUrl}`}>
{post.frontmatter.title}
</PostLink>
</PostTitle>
<PostDate>{post.frontmatter.date}</PostDate>
</PostItemContainer>
)
})}
</React.Fragment>
)
})}
</ul>
</Layout>
)
}
export default Blog
You can’t perform that action at this time.