Skip to content

Commit

Permalink
don't display releases older than a year
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzsequence committed Dec 17, 2024
1 parent b40b416 commit e29d07c
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions src/components/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { StaticQuery, graphql } from 'gatsby';
import { MDXRenderer } from 'gatsby-plugin-mdx';
import { MDXProvider } from '@mdx-js/react';
import { format, subYears } from 'date-fns';

import { headline1, headline2, headline3 } from './releaseHeadlines';

Expand Down Expand Up @@ -35,28 +36,36 @@ const Releases = ({ data }) => {
);
};

export default (props) => (
<StaticQuery
query={graphql`
query {
allTerminusReleasesJson(sort: { fields: [tag_name], order: DESC }) {
edges {
node {
id
tag_name
body
fields {
markdownBody {
childMdx {
body
export default (props) => {
const oneYearAgo = format(subYears(new Date(), 1), 'yyyy-MM-dd');

return (
<StaticQuery
query={graphql`
query($cutoffDate: Date!) {
allTerminusReleasesJson(
sort: { fields: [published_at], order: DESC }
filter: { published_at: { gte: $cutoffDate } }
) {
edges {
node {
id
tag_name
body
fields {
markdownBody {
childMdx {
body
}
}
}
}
}
}
}
}
`}
render={(data) => <Releases data={data} {...props} />}
/>
);
`}
variables={{ cutoffDate: oneYearAgo }}
render={(data) => <Releases data={data} {...props} />}
/>
);
};

0 comments on commit e29d07c

Please sign in to comment.