diff --git a/.changeset/forty-readers-mix.md b/.changeset/forty-readers-mix.md new file mode 100644 index 000000000..98bede85d --- /dev/null +++ b/.changeset/forty-readers-mix.md @@ -0,0 +1,5 @@ +--- +"gitbook": minor +--- + +Support dark-mode specific page cover image diff --git a/bun.lock b/bun.lock index 5a2653c91..e36213e8a 100644 --- a/bun.lock +++ b/bun.lock @@ -26,7 +26,7 @@ "name": "@gitbook/cache-tags", "version": "0.3.1", "dependencies": { - "@gitbook/api": "^0.118.0", + "@gitbook/api": "^0.119.0", "assert-never": "^1.2.1", }, "devDependencies": { @@ -51,7 +51,7 @@ "name": "gitbook", "version": "0.12.0", "dependencies": { - "@gitbook/api": "^0.118.0", + "@gitbook/api": "^0.119.0", "@gitbook/cache-do": "workspace:*", "@gitbook/cache-tags": "workspace:*", "@gitbook/colors": "workspace:*", @@ -150,7 +150,7 @@ "name": "gitbook-v2", "version": "0.3.0", "dependencies": { - "@gitbook/api": "^0.118.0", + "@gitbook/api": "^0.119.0", "@gitbook/cache-tags": "workspace:*", "@opennextjs/cloudflare": "1.1.0", "@sindresorhus/fnv1a": "^3.1.0", @@ -209,7 +209,7 @@ "name": "@gitbook/react-contentkit", "version": "0.7.0", "dependencies": { - "@gitbook/api": "^0.118.0", + "@gitbook/api": "^0.119.0", "@gitbook/icons": "workspace:*", "classnames": "^2.5.1", }, @@ -267,7 +267,7 @@ }, "overrides": { "@codemirror/state": "6.4.1", - "@gitbook/api": "^0.118.0", + "@gitbook/api": "^0.119.0", "react": "^19.0.0", "react-dom": "^19.0.0", }, @@ -632,7 +632,7 @@ "@fortawesome/fontawesome-svg-core": ["@fortawesome/fontawesome-svg-core@6.6.0", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "6.6.0" } }, "sha512-KHwPkCk6oRT4HADE7smhfsKudt9N/9lm6EJ5BVg0tD1yPA5hht837fB87F8pn15D8JfTqQOjhKTktwmLMiD7Kg=="], - "@gitbook/api": ["@gitbook/api@0.118.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-5bpvXyGNsMOn1Ee7uzohDz/yOgxpVyLZMLu6THYwbG9UeY6BFsWISeqTw03COCX42rVLU5zFReDxRTb7lfZtCw=="], + "@gitbook/api": ["@gitbook/api@0.119.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-l2gfJ5+1HT3Sj1OQCh72lUOGU9LV9WbDjgKPjxIFz+NgOhSest1bJ3JhmHP66Xd4ETpmm0YQqnq4y18wKRMjBQ=="], "@gitbook/cache-do": ["@gitbook/cache-do@workspace:packages/cache-do"], diff --git a/package.json b/package.json index 8ee2b3351..b4a3acc96 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "packageManager": "bun@1.2.11", "overrides": { "@codemirror/state": "6.4.1", - "@gitbook/api": "^0.118.0", + "@gitbook/api": "^0.119.0", "react": "^19.0.0", "react-dom": "^19.0.0" }, diff --git a/packages/cache-tags/package.json b/packages/cache-tags/package.json index 37e243bdb..7109f569d 100644 --- a/packages/cache-tags/package.json +++ b/packages/cache-tags/package.json @@ -10,7 +10,7 @@ }, "version": "0.3.1", "dependencies": { - "@gitbook/api": "^0.118.0", + "@gitbook/api": "^0.119.0", "assert-never": "^1.2.1" }, "devDependencies": { diff --git a/packages/gitbook-v2/package.json b/packages/gitbook-v2/package.json index 6eaa3a37c..a0ead700f 100644 --- a/packages/gitbook-v2/package.json +++ b/packages/gitbook-v2/package.json @@ -3,7 +3,7 @@ "version": "0.3.0", "private": true, "dependencies": { - "@gitbook/api": "^0.118.0", + "@gitbook/api": "^0.119.0", "@gitbook/cache-tags": "workspace:*", "@opennextjs/cloudflare": "1.1.0", "@sindresorhus/fnv1a": "^3.1.0", diff --git a/packages/gitbook/e2e/internal.spec.ts b/packages/gitbook/e2e/internal.spec.ts index 925521e02..a6d87fbf8 100644 --- a/packages/gitbook/e2e/internal.spec.ts +++ b/packages/gitbook/e2e/internal.spec.ts @@ -5,6 +5,7 @@ import { CustomizationHeaderPreset, CustomizationIconsStyle, CustomizationSidebarListStyle, + CustomizationThemeMode, } from '@gitbook/api'; import { expect } from '@playwright/test'; import jwt from 'jsonwebtoken'; @@ -681,6 +682,16 @@ const testCases: TestsCase[] = [ url: 'page-options/page-with-cover', run: waitForCookiesDialog, }, + { + name: 'With cover for dark mode', + url: `page-options/page-with-dark-cover${getCustomizationURL({ + themes: { + default: CustomizationThemeMode.Dark, + toggeable: false, + }, + })}`, + run: waitForCookiesDialog, + }, { name: 'With hero cover', url: 'page-options/page-with-hero-cover', diff --git a/packages/gitbook/package.json b/packages/gitbook/package.json index 62952f844..fba4221a8 100644 --- a/packages/gitbook/package.json +++ b/packages/gitbook/package.json @@ -16,7 +16,7 @@ "clean": "rm -rf ./.next && rm -rf ./public/~gitbook/static/icons && rm -rf ./public/~gitbook/static/math" }, "dependencies": { - "@gitbook/api": "^0.118.0", + "@gitbook/api": "^0.119.0", "@gitbook/cache-do": "workspace:*", "@gitbook/cache-tags": "workspace:*", "@gitbook/colors": "workspace:*", diff --git a/packages/gitbook/src/components/PageBody/PageCover.tsx b/packages/gitbook/src/components/PageBody/PageCover.tsx index 29fb1a492..67aabd212 100644 --- a/packages/gitbook/src/components/PageBody/PageCover.tsx +++ b/packages/gitbook/src/components/PageBody/PageCover.tsx @@ -22,6 +22,7 @@ export async function PageCover(props: { }) { const { as, page, cover, context } = props; const resolved = cover.ref ? await resolveContentRef(cover.ref, context) : null; + const resolvedDark = cover.refDark ? await resolveContentRef(cover.refDark, context) : null; return (