diff --git a/packages/gitbook/src/components/SitePage/SitePage.tsx b/packages/gitbook/src/components/SitePage/SitePage.tsx index 5325d48d9..a321ca000 100644 --- a/packages/gitbook/src/components/SitePage/SitePage.tsx +++ b/packages/gitbook/src/components/SitePage/SitePage.tsx @@ -160,21 +160,36 @@ export async function generateSitePageMetadata(props: SitePageProps): Promise; + generic: Array<{ + title?: string; + url: string; + }>; + }>( (acc, alt) => { - // TODO: We can only add language alternates for now as that's all Next.js API supports - // generic alternates are not supported yet if (alt.space?.language) { - acc[alt.space.language] = alt.href; + acc.languages[alt.space.language] = URL.canParse(alt.href) + ? alt.href + : linker.toAbsoluteURL(alt.href); + } else { + acc.generic.push({ + url: URL.canParse(alt.href) ? alt.href : linker.toAbsoluteURL(alt.href), + }); } return acc; }, - {} as Record + { languages: {}, generic: [] } ); return { @@ -189,9 +204,13 @@ export async function generateSitePageMetadata(props: SitePageProps): Promise + // Team at Vercel is aware of this and will ensure it will be omitted when the value is empty in future versions of Next.js + // https://gitbook.slack.com/archives/C04K6MV5W1K/p1763034072958419?thread_ts=1762937203.511629&cid=C04K6MV5W1K + ...(alternates?.generic ? { '': alternates?.generic } : {}), }, }, openGraph: {