Streamline event info page getStaticPaths
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Amy 2021-08-18 21:31:12 -04:00
parent e11db336ac
commit 0b62d2810e
1 changed files with 12 additions and 14 deletions

View File

@ -44,25 +44,23 @@ export const getStaticProps: GetStaticProps<Props, Params> = async (
export const getStaticPaths: GetStaticPaths<Params> = async () => {
const years = await getEventYears();
const terms = (
const events = (
await Promise.all(
years.map(async (year) => {
const termsInYear = await getEventTermsByYear(year);
return termsInYear.map((term) => ({ year, term }));
return await Promise.all(
termsInYear.map(async (term) => {
const eventsInTerm = await getEventsByTerm(year, term);
return eventsInTerm.map((event) => ({
year,
term,
event,
}));
})
);
})
)
).flat();
const events = (
await Promise.all(
terms.map(async (term) => {
const eventsInTerm = await getEventsByTerm(term.year, term.term);
return eventsInTerm.map((event) => ({
...term,
event,
}));
})
)
).flat();
).flat(2);
return {
paths: events.map((params) => ({ params })),