Skip to content

Commit 860fd6d

Browse files
committed
Use system-ui font in icons.
1 parent c43c524 commit 860fd6d

File tree

2 files changed

+4
-30
lines changed
  • packages/gitbook/src

2 files changed

+4
-30
lines changed

packages/gitbook/src/app/middleware/(site)/(core)/~gitbook/icon/route.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ export async function GET(req: NextRequest) {
1010
try {
1111
const pointer = await getSiteContentPointer();
1212
const context = await fetchV1ContextForSitePointer(pointer);
13-
14-
// biome-ignore lint/suspicious/noConsole: we want to log here
15-
console.log(`serving icon for ${context.site.id}`);
1613
return await serveIcon(context, req);
1714
} catch (err) {
1815
// biome-ignore lint/suspicious/noConsole: we want to log here

packages/gitbook/src/routes/icon.tsx

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ export async function serveIcon(context: GitBookSiteContext, req: Request) {
3232

3333
const { site, customization } = context;
3434
const customIcon = 'icon' in customization.favicon ? customization.favicon.icon : null;
35-
36-
console.log(
37-
'icon: serveIcon',
38-
req.url,
39-
customIcon ? 'custom' : 'emoji' in customization.favicon ? 'emoji' : 'fallback'
40-
);
4135
// If the site has a custom icon, redirect to it
4236
if (customIcon) {
4337
const iconUrl = options.theme === 'light' ? customIcon.light : customIcon.dark;
@@ -50,18 +44,6 @@ export async function serveIcon(context: GitBookSiteContext, req: Request) {
5044
}
5145

5246
const contentTitle = site.title;
53-
54-
// Load the font locally to prevent the shared instance used by ImageResponse.
55-
const fontOrigin = await fetch(
56-
new URL('../fonts/Inter/Inter-Regular.ttf', import.meta.url)
57-
).then((res) => res.arrayBuffer());
58-
const dst = new ArrayBuffer(fontOrigin.byteLength);
59-
new Uint8Array(dst).set(new Uint8Array(fontOrigin));
60-
61-
if (('detached' in dst && dst.detached) || dst.byteLength === 0) {
62-
console.log('about to use detached font buffer..');
63-
}
64-
6547
return new ImageResponse(
6648
<div
6749
tw={tcls(options.theme === 'light' ? 'bg-white' : 'bg-black', size.boxStyle)}
@@ -71,7 +53,7 @@ export async function serveIcon(context: GitBookSiteContext, req: Request) {
7153
display: 'flex',
7254
alignItems: 'center',
7355
justifyContent: 'center',
74-
fontFamily: 'Inter',
56+
fontFamily: 'system-ui, sans-serif',
7557
}}
7658
>
7759
<h2
@@ -90,14 +72,9 @@ export async function serveIcon(context: GitBookSiteContext, req: Request) {
9072
{
9173
width: size.width,
9274
height: size.height,
93-
fonts: [
94-
{
95-
data: dst,
96-
name: 'Inter',
97-
weight: 400,
98-
style: 'normal',
99-
},
100-
],
75+
76+
// Explicitly disable any fonts to avoid ArrayBuffer detachment errors.
77+
fonts: [],
10178
}
10279
);
10380
}

0 commit comments

Comments
 (0)