import React from 'react' import { Link, graphql } from 'gatsby' import { GatsbyImage } from 'gatsby-plugin-image' import DefaultLayout from '../components/layout' import SEO from '../components/seo' class BlogIndex extends React.Component { render() { const { data } = this.props const siteTitle = data.site.siteMetadata.title const posts = data.allMarkdownRemark.edges const { currentPage, numPages } = this.props.pageContext const isFirst = currentPage === 1 const isLast = currentPage === numPages const prevPage = currentPage - 1 === 1 ? '/' : `../${currentPage - 1}` const nextPage = `../${currentPage + 1}` return (
{posts.map(({ node }) => { return (
{node.frontmatter.img && node.frontmatter.img.childImageSharp && node.frontmatter.img.childImageSharp.gatsbyImageData && ( )}

{node.frontmatter.title}

{node.excerpt}

{node.frontmatter.date}  —  {node.timeToRead} minute read
) })}
) } } export default BlogIndex export const pageQuery = graphql` query blogPageQuery($skip: Int!, $limit: Int!) { site { siteMetadata { title } } allMarkdownRemark( sort: { fields: [frontmatter___date], order: DESC } limit: $limit skip: $skip ) { edges { node { excerpt fields { slug } timeToRead frontmatter { date(formatString: "YYYY, MMM DD") title img { childImageSharp { gatsbyImageData( placeholder: BLURRED layout: FULL_WIDTH formats: [AUTO, AVIF, WEBP] ) } } } } } } } `