Skip to content

Commit

Permalink
fix: calculate releasedArtists runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshenrik committed Jan 20, 2025
1 parent 842406a commit b7d9c6f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
15 changes: 8 additions & 7 deletions src/layouts/ArtistLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
],
Expand Down
26 changes: 15 additions & 11 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 8 additions & 7 deletions src/pages/program.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -55,7 +56,7 @@ const concertsGroupedByDay = Object.entries(
groupBy(
sortBy(
[
...releasedArtists.filter(
...releasedArtists().filter(
({ frontmatter: { hideFromProgram } }) => !hideFromProgram,
),
...tbaArtists.map((tbaArtist) => ({ frontmatter: tbaArtist })),
Expand Down

0 comments on commit b7d9c6f

Please sign in to comment.