Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

build (docs): lower docs preview build times (#35183)

Charis9846052217ef
diff --git a/apps/docs/app/guides/realtime/[[...slug]]/page.tsx b/apps/docs/app/guides/realtime/[[...slug]]/page.tsx
index 7a19de3cd7b..ef9cd4969f9 100644
--- a/apps/docs/app/guides/realtime/[[...slug]]/page.tsx
+++ b/apps/docs/app/guides/realtime/[[...slug]]/page.tsx
@@ -1,11 +1,10 @@
+import { GuideTemplate } from '~/features/docs/GuidesMdx.template'
import {
- getGuidesMarkdown,
genGuideMeta,
genGuidesStaticParams,
+ getGuidesMarkdown,
} from '~/features/docs/GuidesMdx.utils'
-import { GuideTemplate } from '~/features/docs/GuidesMdx.template'
-
-export const dynamicParams = false
+import { getEmptyArray } from '~/features/helpers.fn'
type Params = { slug?: string[] }
@@ -16,10 +15,15 @@ const RealtimeGuidePage = async ({ params }: { params: Params }) => {
return <GuideTemplate {...data!} />
}
-const generateStaticParams = genGuidesStaticParams('realtime')
+const generateStaticParams =
+ // [Charis 2025-04-21] For some reason, using the IS_PROD export from common
+ // does not work (its type is a function when this is evaluated?)
+ process.env.NEXT_PUBLIC_VERCEL_ENV === 'production'
+ ? genGuidesStaticParams('realtime')
+ : getEmptyArray
const generateMetadata = genGuideMeta((params: { slug?: string[] }) =>
getGuidesMarkdown(['realtime', ...(params.slug ?? [])])
)
export default RealtimeGuidePage
-export { generateStaticParams, generateMetadata }
+export { generateMetadata, generateStaticParams }
diff --git a/apps/docs/features/helpers.fn.ts b/apps/docs/features/helpers.fn.ts
index 8d5113a7030..8f50cc1c243 100644
--- a/apps/docs/features/helpers.fn.ts
+++ b/apps/docs/features/helpers.fn.ts
@@ -1,5 +1,10 @@
type RecObj<T extends object, K extends keyof T> = T[K] extends Array<T> ? T : never
+const EMPTY_ARRAY = new Array(0)
+export function getEmptyArray() {
+ return EMPTY_ARRAY
+}
+
export function deepFilterRec<T extends object, K extends keyof T>(
arr: Array<RecObj<T, K>>,
recKey: K,
@@ -24,6 +29,7 @@ export function deepFilterRec<T extends object, K extends keyof T>(
)
}
-export function pluckPromise<T, K extends keyof T>(promise: Promise<T>, key: K) {
- return promise.then((data) => data[key])
+export async function pluckPromise<T, K extends keyof T>(promise: Promise<T>, key: K) {
+ const data = await promise
+ return data[key]
}