mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-23 11:03:39 +00:00
Use system-ui font in icons.
This commit is contained in:
@@ -10,9 +10,6 @@ export async function GET(req: NextRequest) {
|
||||
try {
|
||||
const pointer = await getSiteContentPointer();
|
||||
const context = await fetchV1ContextForSitePointer(pointer);
|
||||
|
||||
// biome-ignore lint/suspicious/noConsole: we want to log here
|
||||
console.log(`serving icon for ${context.site.id}`);
|
||||
return await serveIcon(context, req);
|
||||
} catch (err) {
|
||||
// biome-ignore lint/suspicious/noConsole: we want to log here
|
||||
|
||||
@@ -32,12 +32,6 @@ export async function serveIcon(context: GitBookSiteContext, req: Request) {
|
||||
|
||||
const { site, customization } = context;
|
||||
const customIcon = 'icon' in customization.favicon ? customization.favicon.icon : null;
|
||||
|
||||
console.log(
|
||||
'icon: serveIcon',
|
||||
req.url,
|
||||
customIcon ? 'custom' : 'emoji' in customization.favicon ? 'emoji' : 'fallback'
|
||||
);
|
||||
// If the site has a custom icon, redirect to it
|
||||
if (customIcon) {
|
||||
const iconUrl = options.theme === 'light' ? customIcon.light : customIcon.dark;
|
||||
@@ -50,18 +44,6 @@ export async function serveIcon(context: GitBookSiteContext, req: Request) {
|
||||
}
|
||||
|
||||
const contentTitle = site.title;
|
||||
|
||||
// Load the font locally to prevent the shared instance used by ImageResponse.
|
||||
const fontOrigin = await fetch(
|
||||
new URL('../fonts/Inter/Inter-Regular.ttf', import.meta.url)
|
||||
).then((res) => res.arrayBuffer());
|
||||
const dst = new ArrayBuffer(fontOrigin.byteLength);
|
||||
new Uint8Array(dst).set(new Uint8Array(fontOrigin));
|
||||
|
||||
if (('detached' in dst && dst.detached) || dst.byteLength === 0) {
|
||||
console.log('about to use detached font buffer..');
|
||||
}
|
||||
|
||||
return new ImageResponse(
|
||||
<div
|
||||
tw={tcls(options.theme === 'light' ? 'bg-white' : 'bg-black', size.boxStyle)}
|
||||
@@ -71,7 +53,7 @@ export async function serveIcon(context: GitBookSiteContext, req: Request) {
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
fontFamily: 'Inter',
|
||||
fontFamily: 'system-ui, sans-serif',
|
||||
}}
|
||||
>
|
||||
<h2
|
||||
@@ -90,14 +72,9 @@ export async function serveIcon(context: GitBookSiteContext, req: Request) {
|
||||
{
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
fonts: [
|
||||
{
|
||||
data: dst,
|
||||
name: 'Inter',
|
||||
weight: 400,
|
||||
style: 'normal',
|
||||
},
|
||||
],
|
||||
|
||||
// Explicitly disable any fonts to avoid ArrayBuffer detachment errors.
|
||||
fonts: [],
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user