diff --git a/src/layouts/ArtistLayout.astro b/src/layouts/ArtistLayout.astro index 341174c..2f288e6 100644 --- a/src/layouts/ArtistLayout.astro +++ b/src/layouts/ArtistLayout.astro @@ -68,15 +68,16 @@ export type ArtistProps = { }; const artistsPages: ArtistProps[] = await Astro.glob("../pages/artist/*.mdx"); -const releasedArtists = artistsPages.filter( - (artist) => - !artist.frontmatter.hideFromProgram && - (!artist.frontmatter.releaseAt || - isBefore(artist.frontmatter.releaseAt, new Date())), -); +const releasedArtists = () => + artistsPages.filter( + (artist) => + !artist.frontmatter.hideFromProgram && + (!artist.frontmatter.releaseAt || + isBefore(artist.frontmatter.releaseAt, new Date())), + ); const sortedArtistsPages = sortBy( [ - ...releasedArtists.filter( + ...releasedArtists().filter( ({ frontmatter: { hideFromArtistList } }) => !hideFromArtistList, ), ], diff --git a/src/pages/index.astro b/src/pages/index.astro index 9c65494..0127044 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -10,18 +10,22 @@ import Spotify from "../components/Spotify.astro"; import Layout from "../layouts/Layout.astro"; const artists = await Astro.glob("../pages/artist/*.mdx"); -const releasedArtists = artists.filter( - (artist) => - !artist.frontmatter.releaseAt || - isBefore(artist.frontmatter.releaseAt, new Date()), -); -const [upcomingArtists, pastArtists] = partition(releasedArtists, (artist) => { - const { - frontmatter: { concertStartAt }, - } = artist; +const releasedArtists = () => + artists.filter( + (artist) => + !artist.frontmatter.releaseAt || + isBefore(artist.frontmatter.releaseAt, new Date()), + ); +const [upcomingArtists, pastArtists] = partition( + releasedArtists(), + (artist) => { + const { + frontmatter: { concertStartAt }, + } = artist; - return new Date(concertStartAt) > new Date(); -}); + return new Date(concertStartAt) > new Date(); + }, +); const byOrder = (a, b) => { const aOrder = a.frontmatter.order || 0; diff --git a/src/pages/program.astro b/src/pages/program.astro index 4700629..7a586fe 100644 --- a/src/pages/program.astro +++ b/src/pages/program.astro @@ -12,12 +12,13 @@ import { formatHumanDate, formatTime } from "../utils/date"; import { imagePathToSrc } from "../utils/images"; const artistsPages = await Astro.glob("../pages/artist/*.mdx"); -const releasedArtists = artistsPages.filter( - (artist) => - !artist.frontmatter.hideFromProgram && - (!artist.frontmatter.releaseAt || - isBefore(artist.frontmatter.releaseAt, new Date())), -); +const releasedArtists = () => + artistsPages.filter( + (artist) => + !artist.frontmatter.hideFromProgram && + (!artist.frontmatter.releaseAt || + isBefore(artist.frontmatter.releaseAt, new Date())), + ); const tbaArtists = [ // { // title: "Jazzlaugs gebursdag m/M. Rexen solo", @@ -55,7 +56,7 @@ const concertsGroupedByDay = Object.entries( groupBy( sortBy( [ - ...releasedArtists.filter( + ...releasedArtists().filter( ({ frontmatter: { hideFromProgram } }) => !hideFromProgram, ), ...tbaArtists.map((tbaArtist) => ({ frontmatter: tbaArtist })),