From 57c137cee6f76200a560c450c2344c7cdd40861f Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Wed, 20 Sep 2023 14:51:26 -0500 Subject: [PATCH] Statically generate grid, [photoId] paths --- src/app/(static)/grid/page.tsx | 3 ++- src/app/(static)/p/[photoId]/layout.tsx | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/(static)/grid/page.tsx b/src/app/(static)/grid/page.tsx index 73af56ec..39f7b2dd 100644 --- a/src/app/(static)/grid/page.tsx +++ b/src/app/(static)/grid/page.tsx @@ -8,7 +8,8 @@ import { getPhotos, getPhotosCount, getUniqueTags } from '@/services/postgres'; import PhotoTag from '@/tag/PhotoTag'; import { Metadata } from 'next'; -export const runtime = 'edge'; +// Revalidate every 12 hours +export const revalidate = 43_200; export async function generateMetadata(): Promise { const photos = await getPhotos(); diff --git a/src/app/(static)/p/[photoId]/layout.tsx b/src/app/(static)/p/[photoId]/layout.tsx index daa2200a..25e815cf 100644 --- a/src/app/(static)/p/[photoId]/layout.tsx +++ b/src/app/(static)/p/[photoId]/layout.tsx @@ -6,6 +6,7 @@ import { import { Metadata } from 'next'; import { getPhoto, + getPhotos, getPhotosTakenAfterPhotoInclusive, getPhotosTakenBeforePhoto, } from '@/services/postgres'; @@ -13,7 +14,15 @@ import { redirect } from 'next/navigation'; import { absolutePathForPhoto, absolutePathForPhotoImage } from '@/site/paths'; import PhotoDetailPage from '@/photo/PhotoDetailPage'; -export const runtime = 'edge'; +// Revalidate every 12 hours +export const revalidate = 43_200; + +export async function generateStaticParams() { + const photos = await getPhotos(); + return photos.map(photo => ({ + slug: photo.id, + })); +} export async function generateMetadata({ params: { photoId },