Created
January 9, 2020 12:34
-
-
Save siisee11/479a4d1edbd8fd3d98e1179d2da446a7 to your computer and use it in GitHub Desktop.
gatsby
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 { graphql } from "gatsby" | |
import { css } from "@emotion/core" | |
import { rhythm } from "../utils/typography" | |
import Layout from "../components/layout" | |
export default ({ data }) => { | |
console.log(data) | |
return ( | |
<Layout> | |
<div> | |
<h1 | |
css={css` | |
display: inline-block; | |
border-bottom: 1px solid; | |
`} | |
> | |
Amazing Pandas Eating Things | |
</h1> | |
<h4>{data.allMarkdownRemark.totalCount} Posts</h4> | |
{data.allMarkdownRemark.edges.map(({ node }) => ( | |
<div key={node.id}> | |
<h3 | |
css={css` | |
margin-bottom: ${rhythm(1 / 4)}; | |
`} | |
> | |
{node.frontmatter.title}{" "} | |
<span | |
css={css` | |
color: #bbb; | |
`} | |
> | |
— {node.frontmatter.date} | |
</span> | |
</h3> | |
<p>{node.excerpt}</p> | |
</div> | |
))} | |
</div> | |
</Layout> | |
) | |
} | |
export const query = graphql` | |
query { | |
allMarkdownRemark { | |
totalCount | |
edges { | |
node { | |
id | |
frontmatter { | |
title | |
date(formatString: "DD MMMM, YYYY") | |
} | |
excerpt | |
} | |
} | |
} | |
} | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment