From 711a44265c5cf40b267937474eed4a1433a569f3 Mon Sep 17 00:00:00 2001 From: Strtus Date: Tue, 19 May 2026 00:28:19 +0800 Subject: [PATCH] Fix image OG grid crash when photo URLs are missing Guard the OG photo grid against empty URL results so prerendering does not crash when an optimized image fetch fails. Co-authored-by: Cursor --- .../components/ImagePhotoGrid.tsx | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/image-response/components/ImagePhotoGrid.tsx b/src/image-response/components/ImagePhotoGrid.tsx index 0b8abd97..fa70c632 100644 --- a/src/image-response/components/ImagePhotoGrid.tsx +++ b/src/image-response/components/ImagePhotoGrid.tsx @@ -59,11 +59,21 @@ export default async function ImagePhotoGrid({ IS_PREVIEW, ); + if (count === 0 || photoUrls.length === 0) { + return null; + } + const renderPhoto = ( - { id, urlData }: typeof photoUrls[number], + photo: (typeof photoUrls)[number] | undefined, width: number, height: number, - ) => + ) => { + if (!photo) { + return null; + } + + const { id, urlData } = photo; + return (
-
; + + ); + }; return (
- {hasSplitLayout + {hasSplitLayout && photoUrls.length >= 3 ? <> {/* Large image (L) */}