Generate static params for tagged photos

This commit is contained in:
Sam Becker 2023-09-20 23:37:04 -05:00
parent 682d331141
commit 3a5ed478fc

View File

@ -7,8 +7,21 @@ import { redirect } from 'next/navigation';
import { absolutePathForPhoto, absolutePathForPhotoImage } from '@/site/paths';
import PhotoDetailPage from '@/photo/PhotoDetailPage';
import { getPhotoCached, getPhotosCached } from '@/cache';
import { getPhotos, getUniqueTags } from '@/services/postgres';
export const runtime = 'edge';
export async function generateStaticParams() {
const params: { params: { photoId: string, tag: string }}[] = [];
const tags = await getUniqueTags();
tags.forEach(async tag => {
const photos = await getPhotos({ tag });
params.push(...photos.map(photo => ({
params: { photoId: photo.id, tag },
})));
});
return params;
}
export async function generateMetadata({
params: { photoId, tag },