Optimize getStaticPaths
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Jared He 2021-08-22 14:05:29 -05:00
parent 9e8b381064
commit 3a6f799538
1 changed files with 10 additions and 8 deletions

View File

@ -121,14 +121,16 @@ export const getStaticProps: GetStaticProps<Props, Params> = async (
export const getStaticPaths: GetStaticPaths<Params> = async () => {
const years = await getEventYears();
const paths = [];
for (const year of years) {
const terms = await getEventTermsByYear(year);
const yearPaths = terms.map((curTerm) => ({
params: { year: year, term: curTerm },
}));
paths.push(...yearPaths);
}
const paths = (
await Promise.all(
years.map(async (year) => {
const terms = await getEventTermsByYear(year);
return terms.map((curTerm) => ({
params: { year: year, term: curTerm },
}));
})
)
).flat();
return {
paths: paths,