Skip to content

Commit 8f7c304

Browse files
authored
Fix crash when rendering ogimage with invalid icon (#3348)
1 parent a3a944d commit 8f7c304

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

packages/gitbook/src/routes/ogimage.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,12 @@ export async function serveOGImage(baseContext: GitBookSiteContext, params: Page
160160
height: 48,
161161
};
162162

163-
if ('icon' in customization.favicon)
164-
return (
165-
<img
166-
{...(await fetchImage(customization.favicon.icon[theme], faviconSize))}
167-
{...faviconSize}
168-
alt="Icon"
169-
/>
170-
);
163+
if ('icon' in customization.favicon) {
164+
const faviconImage = await fetchImage(customization.favicon.icon[theme], faviconSize);
165+
if (faviconImage) {
166+
return <img {...faviconImage} {...faviconSize} alt="Icon" />;
167+
}
168+
}
171169

172170
return (
173171
<SiteDefaultIcon

0 commit comments

Comments
 (0)