-
-
Save amandeepmittal/24bc648b37086bdfc4dcb38655fc44f7 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 { graphql, Link } from 'gatsby'; | |
import Layout from '../components/layout'; | |
const IndexPage = ({ data }) => { | |
const { edges } = data.allMarkdownRemark; | |
return ( | |
<Layout> | |
<div> | |
{edges.map(edge => { | |
const { frontmatter } = edge.node; | |
return ( | |
<div key={frontmatter.path}> | |
<Link to={frontmatter.path}>{frontmatter.title}</Link> | |
| |
<small> | |
{' '} | |
<em>published on</em> {frontmatter.date} | |
</small> | |
<p>{frontmatter.excerpt}</p> | |
<br /> | |
</div> | |
); | |
})} | |
</div> | |
</Layout> | |
); | |
}; | |
export const query = graphql` | |
query HomePageQuery { | |
allMarkdownRemark(sort: { order: DESC, fields: frontmatter___date }) { | |
totalCount | |
edges { | |
node { | |
id | |
frontmatter { | |
title | |
date(formatString: "MMMM DD, YYYY") | |
path | |
tags | |
excerpt | |
} | |
} | |
} | |
} | |
} | |
`; | |
export default IndexPage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment