Implement getAllEvents
This commit is contained in:
parent
5ca822a3e4
commit
6cdab0fd28
|
@ -111,6 +111,47 @@ export async function getUpcomingEvents(): Promise<Event[]> {
|
|||
});
|
||||
}
|
||||
|
||||
export async function getAllEvents() {
|
||||
/* Promise.all implementation
|
||||
const slugs = (
|
||||
await Promise.all(
|
||||
(
|
||||
await getEventYears()
|
||||
).map(
|
||||
async (year) =>
|
||||
await Promise.all(
|
||||
(
|
||||
await getEventTermsByYear(year)
|
||||
).map(async (term) => {
|
||||
return (await getEventsByTerm(year, term)).map((slug) => ({
|
||||
slug,
|
||||
term,
|
||||
year,
|
||||
}));
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
).flat(2);
|
||||
|
||||
return await Promise.all(
|
||||
slugs.map(({ year, term, slug }) => getEventBySlug(year, term, slug))
|
||||
);
|
||||
*/
|
||||
|
||||
const events: Event[] = [];
|
||||
|
||||
for (const year of await getEventYears()) {
|
||||
for (const term of await getEventTermsByYear(year)) {
|
||||
for (const slug of await getEventsByTerm(year, term)) {
|
||||
events.push(await getEventBySlug(year, term, slug));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
export async function getEventsPageProps({
|
||||
year,
|
||||
term,
|
||||
|
|
Loading…
Reference in New Issue