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 <cursoragent@cursor.com>
This commit is contained in:
Strtus 2026-05-19 00:28:19 +08:00
parent a11560b437
commit 711a44265c

View File

@ -59,11 +59,21 @@ export default async function ImagePhotoGrid({
IS_PREVIEW, IS_PREVIEW,
); );
if (count === 0 || photoUrls.length === 0) {
return null;
}
const renderPhoto = ( const renderPhoto = (
{ id, urlData }: typeof photoUrls[number], photo: (typeof photoUrls)[number] | undefined,
width: number, width: number,
height: number, height: number,
) => ) => {
if (!photo) {
return null;
}
const { id, urlData } = photo;
return (
<div <div
key={id} key={id}
style={{ style={{
@ -85,7 +95,9 @@ export default async function ImagePhotoGrid({
objectFit: 'cover', objectFit: 'cover',
}, },
}} /> }} />
</div>; </div>
);
};
return ( return (
<div <div
@ -97,7 +109,7 @@ export default async function ImagePhotoGrid({
gap, gap,
}} }}
> >
{hasSplitLayout {hasSplitLayout && photoUrls.length >= 3
? <> ? <>
{/* Large image (L) */} {/* Large image (L) */}
<div style={{ <div style={{