Skip to content

Commit

Permalink
Merge pull request #10950 from wellcomecollection/limit-months-displayed
Browse files Browse the repository at this point in the history
Only display the the next 4 months (inclusive) on the what's on page
  • Loading branch information
gestchild authored Jun 12, 2024
2 parents 88d5864 + 493b0b7 commit 6019a25
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions content/webapp/components/EventsByMonth/EventsByMonth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const EventsByMonth: FunctionComponent<Props> = ({ events, links }) => {
const { isEnhanced } = useContext(AppContext);
// Group the events into the per-month tabs that we render on the
// What's On page, e.g. a group for May, June, July, ...
const monthsWithEvents = groupEventsByMonth(events).map(
({ month, events }) => {
const monthsWithEvents = groupEventsByMonth(events)
.map(({ month, events }) => {
const id = `${month.month}-${month.year}`.toLowerCase();

return {
Expand All @@ -31,8 +31,9 @@ const EventsByMonth: FunctionComponent<Props> = ({ events, links }) => {
month,
events,
};
}
);
})
.slice(0, 4) // never show more than 4 months
.filter(month => month.events.length > 0); // only include months that have events

// We assume that there will always be some upcoming events scheduled,
// which means there will be at least one month in `monthsWithEvents`
Expand Down

0 comments on commit 6019a25

Please sign in to comment.