From c26049f940fe83d1b981fea76206829b3880138a Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Wed, 6 Nov 2024 03:04:24 +0800 Subject: [PATCH] limit the count of the static pages to avoid the build time being too long during CI --- src/app/[locale]/plugin/[pluginId]/layout.tsx | 3 ++- src/app/[locale]/plugin/[pluginId]/release/[version]/page.tsx | 3 ++- src/utils/build-utils.ts | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 src/utils/build-utils.ts diff --git a/src/app/[locale]/plugin/[pluginId]/layout.tsx b/src/app/[locale]/plugin/[pluginId]/layout.tsx index 3988a8e..40333ce 100644 --- a/src/app/[locale]/plugin/[pluginId]/layout.tsx +++ b/src/app/[locale]/plugin/[pluginId]/layout.tsx @@ -1,6 +1,7 @@ import { createSimplePlugin } from "@/catalogue/conversion"; import { getEverything, getPlugin, getPluginOr404 } from "@/catalogue/data"; import { CommonContentLayout } from "@/components/layout/common-content-layout"; +import { staticParamsMaxSize } from "@/utils/build-utils"; import { Divider } from "@mantine/core"; import { getTranslations, unstable_setRequestLocale } from "next-intl/server"; import React from "react"; @@ -20,7 +21,7 @@ export async function generateMetadata({params: {locale, pluginId}}: {params: {l export async function generateStaticParams() { const everything = await getEverything() - return Object.keys(everything.plugins).map(pluginId => ({pluginId})) + return Object.keys(everything.plugins).map(pluginId => ({pluginId})).slice(0, staticParamsMaxSize) } interface LayoutProps { diff --git a/src/app/[locale]/plugin/[pluginId]/release/[version]/page.tsx b/src/app/[locale]/plugin/[pluginId]/release/[version]/page.tsx index 01f48e8..e1121c0 100644 --- a/src/app/[locale]/plugin/[pluginId]/release/[version]/page.tsx +++ b/src/app/[locale]/plugin/[pluginId]/release/[version]/page.tsx @@ -1,6 +1,7 @@ import { createSimplePlugin } from "@/catalogue/conversion"; import { getEverything, getPlugin, getPluginOr404 } from "@/catalogue/data"; import { AllOfAPlugin, ReleaseInfo } from "@/catalogue/meta-types"; +import { staticParamsMaxSize } from "@/utils/build-utils"; import { getTranslations, unstable_setRequestLocale } from "next-intl/server"; import { notFound } from "next/navigation"; import { ReleaseDisplay } from "./release-display"; @@ -45,7 +46,7 @@ export async function generateStaticParams({params}: {params: {pluginId: string} if (plugin.release) { return plugin.release.releases.map(r => { return {version: r.meta.version} - }) + }).slice(0, staticParamsMaxSize) } else { return [] } diff --git a/src/utils/build-utils.ts b/src/utils/build-utils.ts new file mode 100644 index 0000000..a99943e --- /dev/null +++ b/src/utils/build-utils.ts @@ -0,0 +1,3 @@ +// limit the count of the static pages to avoid the build time being too long during CI +// we still keep a few generateStaticParams() here to validate that the pages are build-able +export const staticParamsMaxSize = 10