diff --git a/src/app/p/[photoId]/image/route.tsx b/src/app/p/[photoId]/image/route.tsx index 01ab1df0..331977a1 100644 --- a/src/app/p/[photoId]/image/route.tsx +++ b/src/app/p/[photoId]/image/route.tsx @@ -1,9 +1,7 @@ -// import { auth } from '@/auth'; -// import { getImageCacheHeadersForAuth, getPhotoCached } from '@/cache'; -// import { getPhotoCached } from '@/cache'; +import { auth } from '@/auth'; +import { getImageCacheHeadersForAuth, getPhotoCached } from '@/cache'; import { IMAGE_OG_DIMENSION } from '@/photo/image-response'; import PhotoImageResponse from '@/photo/image-response/PhotoImageResponse'; -import { getPhoto } from '@/services/vercel-postgres'; import { getIBMPlexMonoMedium } from '@/site/font'; import { ImageResponse } from 'next/og'; @@ -18,9 +16,9 @@ export async function GET( { fontFamily, fonts }, // headers, ] = await Promise.all([ - getPhoto(context.params.photoId), + getPhotoCached(context.params.photoId), getIBMPlexMonoMedium(), - // getImageCacheHeadersForAuth(await auth()), + getImageCacheHeadersForAuth(await auth()), ]); if (!photo) { return new Response('Photo not found', { status: 404 }); } diff --git a/src/app/p/[photoId]/layout.tsx b/src/app/p/[photoId]/layout.tsx index 69db9114..176c81c2 100644 --- a/src/app/p/[photoId]/layout.tsx +++ b/src/app/p/[photoId]/layout.tsx @@ -12,12 +12,8 @@ import { absolutePathForPhotoImage, } from '@/site/paths'; import PhotoDetailPage from '@/photo/PhotoDetailPage'; -// import { getPhotoCached, getPhotosNearIdCached } from '@/cache'; -import { - getPhoto, - getPhotoIds, - getPhotosNearId, -} from '@/services/vercel-postgres'; +import { getPhotoCached, getPhotosNearIdCached } from '@/cache'; +import { getPhotoIds } from '@/services/vercel-postgres'; export async function generateStaticParams() { const photos = await getPhotoIds({ limit: 10 }); @@ -31,7 +27,7 @@ interface PhotoProps { export async function generateMetadata({ params: { photoId }, }:PhotoProps): Promise { - const photo = await getPhoto(photoId); + const photo = await getPhotoCached(photoId); if (!photo) { return {}; } @@ -62,7 +58,7 @@ export default async function PhotoPage({ params: { photoId }, children, }: PhotoProps & { children: React.ReactNode }) { - const photos = await getPhotosNearId( + const photos = await getPhotosNearIdCached( photoId, GRID_THUMBNAILS_TO_SHOW_MAX + 2, ); @@ -74,7 +70,7 @@ export default async function PhotoPage({ const isPhotoFirst = photos.findIndex(p => p.id === photoId) === 0; // Warm OG image without waiting on response - // fetch(absolutePathForPhotoImage(photo)); + fetch(absolutePathForPhotoImage(photo)); return <> {children} diff --git a/src/app/p/[photoId]/share/page.tsx b/src/app/p/[photoId]/share/page.tsx index b62cba08..fff8c1ba 100644 --- a/src/app/p/[photoId]/share/page.tsx +++ b/src/app/p/[photoId]/share/page.tsx @@ -1,5 +1,5 @@ +import { getPhotoCached } from '@/cache'; import PhotoShareModal from '@/photo/PhotoShareModal'; -import { getPhoto } from '@/services/vercel-postgres'; import { PATH_ROOT } from '@/site/paths'; import { redirect } from 'next/navigation'; @@ -8,7 +8,7 @@ export default async function Share({ }: { params: { photoId: string } }) { - const photo = await getPhoto(photoId); + const photo = await getPhotoCached(photoId); if (!photo) { return redirect(PATH_ROOT); }