Created
July 29, 2019 04:48
-
-
Save yomete/87381558920f764d95596ee434313d8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react" | |
import { Link, graphql } from "gatsby" | |
import Bio from "../components/bio" | |
import Layout from "../components/layout" | |
import SEO from "../components/seo" | |
import { rhythm } from "../utils/typography" | |
interface Props { | |
data: { | |
allMarkdownRemark: any | |
site: { | |
siteMetadata: { | |
title: string | |
} | |
} | |
} | |
} | |
const BlogIndex = ({ data }: Props) => { | |
const siteTitle = data.site.siteMetadata.title | |
const posts = data.allMarkdownRemark.edges | |
return ( | |
<Layout location={window.location} title={siteTitle}> | |
<SEO title="All posts" /> | |
<Bio /> | |
{posts.map(({ node }) => { | |
const title = node.frontmatter.title || node.fields.slug | |
return ( | |
<div key={node.fields.slug}> | |
<h3 | |
style={{ | |
marginBottom: rhythm(1 / 4), | |
}} | |
> | |
<Link style={{ boxShadow: `none` }} to={node.fields.slug}> | |
{title} | |
</Link> | |
</h3> | |
<small>{node.frontmatter.date}</small> | |
<p | |
dangerouslySetInnerHTML={{ | |
__html: node.frontmatter.description || node.excerpt, | |
}} | |
/> | |
</div> | |
) | |
})} | |
</Layout> | |
) | |
} | |
export default BlogIndex | |
export const pageQuery = graphql` | |
query { | |
site { | |
siteMetadata { | |
title | |
} | |
} | |
allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) { | |
edges { | |
node { | |
excerpt | |
fields { | |
slug | |
} | |
frontmatter { | |
date(formatString: "MMMM DD, YYYY") | |
title | |
description | |
} | |
} | |
} | |
} | |
} | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment