diff --git a/.changeset/pretty-balloons-fold.md b/.changeset/pretty-balloons-fold.md
new file mode 100644
index 0000000000..b501879843
--- /dev/null
+++ b/.changeset/pretty-balloons-fold.md
@@ -0,0 +1,5 @@
+---
+"gitbook": patch
+---
+
+Fix rendering of ogimage when logo or icon are AVIF images.
diff --git a/packages/gitbook/src/routes/ogimage.tsx b/packages/gitbook/src/routes/ogimage.tsx
index 653fc8fc3b..4035f54bef 100644
--- a/packages/gitbook/src/routes/ogimage.tsx
+++ b/packages/gitbook/src/routes/ogimage.tsx
@@ -8,6 +8,7 @@ import { ImageResponse } from 'next/og';
import { type PageParams, fetchPageData } from '@/components/SitePage';
import { getFontSourcesToPreload } from '@/fonts/custom';
import { getAssetURL } from '@/lib/assets';
+import { getExtension } from '@/lib/paths';
import { filterOutNullable } from '@/lib/typescript';
import { getCacheTag } from '@gitbook/cache-tags';
import type { GitBookSiteContext } from '@v2/lib/context';
@@ -32,7 +33,6 @@ export async function serveOGImage(baseContext: GitBookSiteContext, params: Page
}
// Compute all text to load only the necessary fonts
- const contentTitle = customization.header.logo ? '' : site.title;
const pageTitle = page
? page.title.length > 64
? `${page.title.slice(0, 64)}...`
@@ -52,7 +52,7 @@ export async function serveOGImage(baseContext: GitBookSiteContext, params: Page
const fontFamily = customization.styling.font ?? CustomizationDefaultFont.Inter;
const regularText = pageDescription;
- const boldText = `${contentTitle}${pageTitle}`;
+ const boldText = `${site.title} ${pageTitle}`;
const fonts = (
await Promise.all([
@@ -164,10 +164,28 @@ export async function serveOGImage(baseContext: GitBookSiteContext, params: Page
)
)
);
+ if (!iconImage) {
+ throw new Error('Icon image should always be fetchable');
+ }
+
return ;
};
- const [favicon, { fontFamily, fonts }] = await Promise.all([faviconLoader(), fontLoader()]);
+ const logoLoader = async () => {
+ if (!customization.header.logo) {
+ return null;
+ }
+
+ return await fetchImage(
+ useLightTheme ? customization.header.logo.light : customization.header.logo.dark
+ );
+ };
+
+ const [favicon, logo, { fontFamily, fonts }] = await Promise.all([
+ faviconLoader(),
+ logoLoader(),
+ fontLoader(),
+ ]);
return new ImageResponse(