import React from 'react' import { Link } from 'react-router' import sortBy from 'lodash/sortBy' import moment from 'moment' import Helmet from 'react-helmet' import { prefixLink } from 'gatsby-helpers' import access from 'safe-access' import { config } from 'config' import SitePost from '../components/SitePost' import SiteSidebar from '../components/SiteSidebar' class SiteIndex extends React.Component { render() { const pageLinks = [] // Sort pages. const sortedPages = sortBy(this.props.route.pages, (page) => access(page, 'data.date') ).reverse() sortedPages.forEach((page) => { if (access(page, 'file.ext') === 'md' && access(page, 'data.layout') === 'post') { const title = access(page, 'data.title') || page.path const description = access(page, 'data.description') const datePublished = access(page, 'data.date') const category = access(page, 'data.category') pageLinks.push(