From a4915afb8a1c3354c1925f98b3fd8ff9e4a05f27 Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Wed, 25 Nov 2020 16:10:10 +0200 Subject: [PATCH] generate all month options xsearch --- pages/xsearch/[[...slug]].tsx | 69 +++++++++++++++-------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/pages/xsearch/[[...slug]].tsx b/pages/xsearch/[[...slug]].tsx index 98413456f..a1cab821a 100644 --- a/pages/xsearch/[[...slug]].tsx +++ b/pages/xsearch/[[...slug]].tsx @@ -89,48 +89,39 @@ export const getStaticPaths: GetStaticPaths = async () => { orderBy: [{ year: "desc" }, { month: "desc" }], }); - if (!mostRecentResult) return { paths: [], fallback: true }; + if (!mostRecentResult) return { paths: [], fallback: false }; return { - paths: ["SZ", "TC", "RM", "CB"].map((mode) => ({ - params: { - slug: ["" + mostRecentResult.year, "" + mostRecentResult.month, mode], - }, - })), - fallback: true, + paths: getMonthOptions(mostRecentResult.month, mostRecentResult.year) + .flatMap(({ month, year }) => [ + { + params: { + slug: [year, month, "SZ"], + }, + }, + { + params: { + slug: [year, month, "TC"], + }, + }, + { + params: { + slug: [year, month, "RM"], + }, + }, + { + params: { + slug: [year, month, "CB"], + }, + }, + ]) + .concat({ + params: { + slug: [], + }, + }), + fallback: false, }; - - // return { - // paths: getMonthOptions(mostRecentResult.month, mostRecentResult.year) - // .flatMap(({ month, year }) => [ - // { - // params: { - // slug: [year, month, "SZ"], - // }, - // }, - // { - // params: { - // slug: [year, month, "TC"], - // }, - // }, - // { - // params: { - // slug: [year, month, "RM"], - // }, - // }, - // { - // params: { - // slug: [year, month, "CB"], - // }, - // }, - // ]) - // .concat({ - // params: { - // slug: [], - // }, - // }), - // fallback: false, - // }; }; export const getStaticProps: GetStaticProps = async ({ params }) => {