From e0bd04f641e4d34ba23c2e929dcdb6b87d6e13cc Mon Sep 17 00:00:00 2001 From: Zeno Kapitein Date: Tue, 25 Aug 2026 12:08:03 +0200 Subject: [PATCH] Render headings with the site's heading font (#4531) Co-authored-by: Claude Opus 5 --- .changeset/site-heading-font.md | 5 ++ bun.lock | 4 +- package.json | 2 +- packages/gitbook/e2e/customers.spec.ts | 5 -- .../gitbook/src/components/AIChat/AIChat.tsx | 2 +- .../src/components/DocumentView/Heading.tsx | 1 + .../components/Embeddable/EmbeddableFrame.tsx | 2 +- .../components/Footer/FooterLinksGroup.tsx | 2 +- .../src/components/Header/HeaderLogo.tsx | 1 + .../gitbook/src/components/PDF/PDFPage.tsx | 8 ++- .../src/components/PageBody/PageHeader.tsx | 1 + .../RootLayout/CustomizationRootLayout.tsx | 10 +++ .../src/components/RootLayout/globals.css | 11 ++++ .../components/Search/LocalSearchResults.tsx | 2 +- .../Search/SearchPageResultItem.tsx | 2 +- .../SiteOAuthConsent/ConsentScreen.tsx | 6 +- .../components/SitePage/SitePageNotFound.tsx | 12 +++- .../TableOfContents/PageGroupItem.tsx | 2 +- packages/gitbook/src/fonts/custom.ts | 8 ++- packages/gitbook/src/fonts/default.ts | 15 +++-- packages/gitbook/src/fonts/heading.test.ts | 64 +++++++++++++++++++ packages/gitbook/src/fonts/heading.ts | 21 ++++++ packages/gitbook/src/fonts/index.ts | 9 ++- packages/gitbook/src/fonts/types.ts | 3 + packages/gitbook/tailwind.config.ts | 2 + 25 files changed, 166 insertions(+), 34 deletions(-) create mode 100644 .changeset/site-heading-font.md create mode 100644 packages/gitbook/src/fonts/heading.test.ts create mode 100644 packages/gitbook/src/fonts/heading.ts diff --git a/.changeset/site-heading-font.md b/.changeset/site-heading-font.md new file mode 100644 index 000000000..f31cc2a09 --- /dev/null +++ b/.changeset/site-heading-font.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Render headings with the site's heading font when one is configured, falling back to the main font otherwise. diff --git a/bun.lock b/bun.lock index 82752faa5..aea449415 100644 --- a/bun.lock +++ b/bun.lock @@ -354,7 +354,7 @@ }, "catalog": { "@base-ui/react": "^1.7.0", - "@gitbook/api": "0.195.0", + "@gitbook/api": "0.196.0", "@scalar/api-client-react": "^1.3.46", "@tsconfig/node20": "^20.1.6", "@tsconfig/strictest": "^2.0.6", @@ -726,7 +726,7 @@ "@fortawesome/fontawesome-svg-core": ["@fortawesome/fontawesome-svg-core@7.2.0", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "7.2.0" } }, "sha512-6639htZMjEkwskf3J+e6/iar+4cTNM9qhoWuRfj9F3eJD6r7iCzV1SWnQr2Mdv0QT0suuqU8BoJCZUyCtP9R4Q=="], - "@gitbook/api": ["@gitbook/api@0.195.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-66OGIiiKUfHB7dF8fb9Ai8PkhQldD4SSQXHZ+X+SSEki2WXpgn6ze+PEXRQvDsJj2JKEvD9A7FfaGzUYiYn9hA=="], + "@gitbook/api": ["@gitbook/api@0.196.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-14f3LXiZljPuxFtYbsdH9mkXN4jucRBnF3QpSACuACDdvJHpTqGsCe52chg3nj72XBbMjD57BsXGklY+IYz9gw=="], "@gitbook/browser-types": ["@gitbook/browser-types@workspace:packages/browser-types"], diff --git a/package.json b/package.json index 7917ffa56..4e3cfc099 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@tsconfig/strictest": "^2.0.6", "@tsconfig/node20": "^20.1.6", "@base-ui/react": "^1.7.0", - "@gitbook/api": "0.195.0", + "@gitbook/api": "0.196.0", "@scalar/api-client-react": "^1.3.46", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0", diff --git a/packages/gitbook/e2e/customers.spec.ts b/packages/gitbook/e2e/customers.spec.ts index 7f7ba2abf..692d428d4 100644 --- a/packages/gitbook/e2e/customers.spec.ts +++ b/packages/gitbook/e2e/customers.spec.ts @@ -308,11 +308,6 @@ const testCases: TestsCase[] = [ contentBaseURL: 'https://docs.triumpharcade.com', tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], }, - { - name: 'docs.nats.io', - contentBaseURL: 'https://docs.nats.io', - tests: [{ name: 'Home', url: '/', run: waitForCookiesDialog }], - }, { name: 'help.glpi-project.org', contentBaseURL: 'https://help.glpi-project.org', diff --git a/packages/gitbook/src/components/AIChat/AIChat.tsx b/packages/gitbook/src/components/AIChat/AIChat.tsx index ab83ba530..1c0e8163a 100644 --- a/packages/gitbook/src/components/AIChat/AIChat.tsx +++ b/packages/gitbook/src/components/AIChat/AIChat.tsx @@ -260,7 +260,7 @@ export function AIChatBody(props: {
diff --git a/packages/gitbook/src/components/DocumentView/Heading.tsx b/packages/gitbook/src/components/DocumentView/Heading.tsx index b61433a0b..dc1a8271d 100644 --- a/packages/gitbook/src/components/DocumentView/Heading.tsx +++ b/packages/gitbook/src/components/DocumentView/Heading.tsx @@ -31,6 +31,7 @@ export async function Heading(props: BlockProps) { className={tcls( textStyle.textSize, 'heading', + 'font-heading', 'pdf-heading', 'block', 'pr-6', diff --git a/packages/gitbook/src/components/Embeddable/EmbeddableFrame.tsx b/packages/gitbook/src/components/Embeddable/EmbeddableFrame.tsx index 3d791824d..44b8fafa3 100644 --- a/packages/gitbook/src/components/Embeddable/EmbeddableFrame.tsx +++ b/packages/gitbook/src/components/Embeddable/EmbeddableFrame.tsx @@ -87,7 +87,7 @@ export function EmbeddableFrameBody(props: { children: React.ReactNode; classNam export function EmbeddableFrameTitle(props: { children: React.ReactNode }) { const { children } = props; - return
{children}
; + return
{children}
; } export function EmbeddableFrameClose() { diff --git a/packages/gitbook/src/components/Footer/FooterLinksGroup.tsx b/packages/gitbook/src/components/Footer/FooterLinksGroup.tsx index 838ecda07..30e2f1853 100644 --- a/packages/gitbook/src/components/Footer/FooterLinksGroup.tsx +++ b/packages/gitbook/src/components/Footer/FooterLinksGroup.tsx @@ -19,7 +19,7 @@ export function FooterLinksGroup(props: { return (