Adjust conditional generateStaticParams syntax
This commit is contained in:
parent
bda0cd27b3
commit
d16db44869
@ -16,16 +16,17 @@ import { getPhotosNearIdCached } from '@/photo/cache';
|
|||||||
import { getPhotoIds } from '@/services/vercel-postgres';
|
import { getPhotoIds } from '@/services/vercel-postgres';
|
||||||
import { STATICALLY_OPTIMIZED } from '@/site/config';
|
import { STATICALLY_OPTIMIZED } from '@/site/config';
|
||||||
|
|
||||||
const generateStaticParams = STATICALLY_OPTIMIZED
|
export let generateStaticParams:
|
||||||
? async () => {
|
(() => Promise<{ params: { photoId: string } }[]>) | undefined = undefined;
|
||||||
|
|
||||||
|
if (STATICALLY_OPTIMIZED) {
|
||||||
|
generateStaticParams = async () => {
|
||||||
const photos = await getPhotoIds({ limit: GENERATE_STATIC_PARAMS_LIMIT });
|
const photos = await getPhotoIds({ limit: GENERATE_STATIC_PARAMS_LIMIT });
|
||||||
return photos.map(photoId => ({
|
return photos.map(photoId => ({
|
||||||
params: { photoId },
|
params: { photoId },
|
||||||
}));
|
}));
|
||||||
}
|
};
|
||||||
: undefined;
|
}
|
||||||
|
|
||||||
export { generateStaticParams };
|
|
||||||
|
|
||||||
interface PhotoProps {
|
interface PhotoProps {
|
||||||
params: { photoId: string }
|
params: { photoId: string }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user