diff --git a/src/components/releases.js b/src/components/releases.js index 36f6c33776..f818635d4b 100644 --- a/src/components/releases.js +++ b/src/components/releases.js @@ -1,49 +1,51 @@ -import React from "react" -import { StaticQuery, graphql } from "gatsby" -import { MDXRenderer } from "gatsby-plugin-mdx" -import { MDXProvider } from "@mdx-js/react" +import React from 'react'; +import { StaticQuery, graphql } from 'gatsby'; +import { MDXRenderer } from 'gatsby-plugin-mdx'; +import { MDXProvider } from '@mdx-js/react'; +import { subYears, parseISO, isAfter } from 'date-fns'; -import { headline1, headline2, headline3 } from "./releaseHeadlines" +import { headline1, headline2, headline3 } from './releaseHeadlines'; const shortcodes = { h1: headline1, h2: headline2, h3: headline3, -} +}; -const Releases = ({ data }) => ( - <> - {data.allTerminusReleasesJson.edges.map((release, i) => { - return ( +const Releases = ({ data }) => { + const oneYearAgo = subYears(new Date(), 1); + + // Filter releases that are newer than one year + const filteredReleases = data.allTerminusReleasesJson.edges.filter((release) => + isAfter(parseISO(release.node.fields.markdownBody.childMdx.body.published_at), oneYearAgo) + ); + + return ( + <> + {filteredReleases.map((release, i) => (