diff --git a/packages/gitbook/src/routes/ogimage.tsx b/packages/gitbook/src/routes/ogimage.tsx index d0e6ceb6e..214b7c4c2 100644 --- a/packages/gitbook/src/routes/ogimage.tsx +++ b/packages/gitbook/src/routes/ogimage.tsx @@ -20,6 +20,10 @@ import { getExtension } from '@/lib/paths'; import { getCacheTag } from '@gitbook/cache-tags'; import { SiteDefaultIcon } from './icon'; +// Upper bound on the rendered title length. Kept generous so full titles are +// shown (the font scales down to fit); only pathological titles get clipped. +const MAX_TITLE_LENGTH = 128; + /** * Render the OpenGraph image for a site content. */ @@ -40,8 +44,8 @@ export async function serveOGImage(baseContext: GitBookSiteContext, params: Page // Compute all text to load only the necessary fonts const pageTitle = page - ? page.title.length > 64 - ? `${page.title.slice(0, 64)}...` + ? page.title.length > MAX_TITLE_LENGTH + ? `${page.title.slice(0, MAX_TITLE_LENGTH)}...` : page.title : 'Not found'; const pageDescription = @@ -199,7 +203,8 @@ export async function serveOGImage(baseContext: GitBookSiteContext, params: Page {/* Title and description */}