Generate static params for photo detail pages

This commit is contained in:
Sam Becker 2024-01-19 12:11:42 -06:00
parent 4d4e4fff54
commit 4887f93bfc
2 changed files with 9 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import {
GENERATE_STATIC_PARAMS_LIMIT,
GRID_THUMBNAILS_TO_SHOW_MAX,
descriptionForPhoto,
titleForPhoto,
@ -12,8 +13,13 @@ import {
} from '@/site/paths';
import PhotoDetailPage from '@/photo/PhotoDetailPage';
import { getPhotoCached, getPhotosNearIdCached } from '@/cache';
import { getPhotos } from '@/services/vercel-postgres';
export async function generateStaticParams() {
const photos = await getPhotos({ limit: GENERATE_STATIC_PARAMS_LIMIT });
return photos.map(({ id }) => ({ photoId: id }));
}
export const runtime = 'edge';
interface PhotoProps {
params: { photoId: string }

View File

@ -11,6 +11,8 @@ import {
import camelcaseKeys from 'camelcase-keys';
import type { Metadata } from 'next';
export const GENERATE_STATIC_PARAMS_LIMIT = 1000;
export const PHOTO_LOAD_MULTIPLE_ROOT =
process.env.NODE_ENV === 'development' ? 2 : 12;
export const PHOTO_LOAD_MULTIPLE_GRID =