import React, { Fragment, PureComponent } from 'react' import PropTypes from 'prop-types' import { Link, graphql, StaticQuery } from 'gatsby' import Image from '../atoms/Image' import styles from './RelatedPosts.module.scss' const query = graphql` query { allMarkdownRemark(sort: { order: DESC, fields: [fields___date] }) { edges { node { id frontmatter { title type linkurl tags image { childImageSharp { ...ImageFluidThumb } } } fields { slug date(formatString: "MMMM DD, YYYY") } } } } } ` const postsWithDataFilter = (postsArray, key, valuesToFind) => { const newArray = postsArray.filter(post => { const frontmatterKey = post.node.frontmatter[key] if ( frontmatterKey !== null && frontmatterKey.some(r => valuesToFind.includes(r)) ) { return post } }) return newArray } const PostItem = ({ post }) => { return (