From b02f67b474d0f4f41bd6d7f212298dff6738ffac Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Fri, 18 Aug 2017 09:24:58 -0400 Subject: [PATCH] Make frontpage list more interesting --- package.json | 2 +- src/pages/index.js | 68 +++++++++++++++++++++++++--------------------- yarn.lock | 6 ++-- 3 files changed, 41 insertions(+), 35 deletions(-) diff --git a/package.json b/package.json index d64298b..a5a7e60 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "url": "https://github.com/gatsbyjs/gatsby-starter-blog/issues" }, "dependencies": { - "gatsby": "^1.8.10", + "gatsby": "^1.8.11", "gatsby-link": "^1.6.7", "gatsby-plugin-google-analytics": "^1.0.3", "gatsby-plugin-manifest": "^1.0.3", diff --git a/src/pages/index.js b/src/pages/index.js index d990a59..794f56a 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -1,42 +1,46 @@ -import React from 'react' -import Link from 'gatsby-link' -import get from 'lodash/get' -import Helmet from 'react-helmet' +import React from "react" +import Link from "gatsby-link" +import get from "lodash/get" +import Helmet from "react-helmet" -import Bio from '../components/Bio' -import { rhythm } from '../utils/typography' +import Bio from "../components/Bio" +import { rhythm } from "../utils/typography" class BlogIndex extends React.Component { render() { - // console.log("props", this.props) - const pageLinks = [] - const siteTitle = get(this, 'props.data.site.siteMetadata.title') - const posts = get(this, 'props.data.allMarkdownRemark.edges') - posts.forEach(post => { - if (post.node.path !== '/404/') { - const title = get(post, 'node.frontmatter.title') || post.node.path - pageLinks.push( -
  • - - {post.node.frontmatter.title} - -
  • - ) - } - }) + const siteTitle = get(this, "props.data.site.siteMetadata.title") + const posts = get(this, "props.data.allMarkdownRemark.edges") return (
    - + -
      - {pageLinks} -
    + {posts.map(post => { + if (post.node.path !== "/404/") { + const title = get(post, "node.frontmatter.title") || post.node.path + return ( +
    +

    + + {post.node.frontmatter.title} + +

    + + {post.node.frontmatter.date} + +

    +

    + ) + } + })}
    ) } @@ -58,8 +62,10 @@ export const pageQuery = graphql` allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) { edges { node { + excerpt frontmatter { path + date(formatString: "DD MMMM, YYYY") } frontmatter { title diff --git a/yarn.lock b/yarn.lock index ecba2b9..4a74a33 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3289,9 +3289,9 @@ gatsby-transformer-sharp@^1.6.0: fs-extra "^4.0.0" image-size "^0.6.0" -gatsby@^1.8.10: - version "1.8.10" - resolved "https://registry.yarnpkg.com/gatsby/-/gatsby-1.8.10.tgz#7acd034ca9c3101cc51e8c7aaebe39c9cd315ce0" +gatsby@^1.8.11: + version "1.8.11" + resolved "https://registry.yarnpkg.com/gatsby/-/gatsby-1.8.11.tgz#1602d67163709a220dceb095a8e55ea4c45dc44a" dependencies: async "^2.1.2" babel-code-frame "^6.22.0"