Skip to content

Commit fa12f9e

Browse files
authored
Page cover dark-mode specific (#3287)
1 parent 33726c8 commit fa12f9e

File tree

9 files changed

+34
-11
lines changed

9 files changed

+34
-11
lines changed

.changeset/forty-readers-mix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": minor
3+
---
4+
5+
Support dark-mode specific page cover image

bun.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"name": "@gitbook/cache-tags",
2727
"version": "0.3.1",
2828
"dependencies": {
29-
"@gitbook/api": "^0.118.0",
29+
"@gitbook/api": "^0.119.0",
3030
"assert-never": "^1.2.1",
3131
},
3232
"devDependencies": {
@@ -51,7 +51,7 @@
5151
"name": "gitbook",
5252
"version": "0.12.0",
5353
"dependencies": {
54-
"@gitbook/api": "^0.118.0",
54+
"@gitbook/api": "^0.119.0",
5555
"@gitbook/cache-do": "workspace:*",
5656
"@gitbook/cache-tags": "workspace:*",
5757
"@gitbook/colors": "workspace:*",
@@ -150,7 +150,7 @@
150150
"name": "gitbook-v2",
151151
"version": "0.3.0",
152152
"dependencies": {
153-
"@gitbook/api": "^0.118.0",
153+
"@gitbook/api": "^0.119.0",
154154
"@gitbook/cache-tags": "workspace:*",
155155
"@opennextjs/cloudflare": "1.1.0",
156156
"@sindresorhus/fnv1a": "^3.1.0",
@@ -209,7 +209,7 @@
209209
"name": "@gitbook/react-contentkit",
210210
"version": "0.7.0",
211211
"dependencies": {
212-
"@gitbook/api": "^0.118.0",
212+
"@gitbook/api": "^0.119.0",
213213
"@gitbook/icons": "workspace:*",
214214
"classnames": "^2.5.1",
215215
},
@@ -267,7 +267,7 @@
267267
},
268268
"overrides": {
269269
"@codemirror/state": "6.4.1",
270-
"@gitbook/api": "^0.118.0",
270+
"@gitbook/api": "^0.119.0",
271271
"react": "^19.0.0",
272272
"react-dom": "^19.0.0",
273273
},
@@ -632,7 +632,7 @@
632632

633633
"@fortawesome/fontawesome-svg-core": ["@fortawesome/[email protected]", "", { "dependencies": { "@fortawesome/fontawesome-common-types": "6.6.0" } }, "sha512-KHwPkCk6oRT4HADE7smhfsKudt9N/9lm6EJ5BVg0tD1yPA5hht837fB87F8pn15D8JfTqQOjhKTktwmLMiD7Kg=="],
634634

635-
"@gitbook/api": ["@gitbook/api@0.118.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-5bpvXyGNsMOn1Ee7uzohDz/yOgxpVyLZMLu6THYwbG9UeY6BFsWISeqTw03COCX42rVLU5zFReDxRTb7lfZtCw=="],
635+
"@gitbook/api": ["@gitbook/api@0.119.0", "", { "dependencies": { "event-iterator": "^2.0.0", "eventsource-parser": "^3.0.0" } }, "sha512-l2gfJ5+1HT3Sj1OQCh72lUOGU9LV9WbDjgKPjxIFz+NgOhSest1bJ3JhmHP66Xd4ETpmm0YQqnq4y18wKRMjBQ=="],
636636

637637
"@gitbook/cache-do": ["@gitbook/cache-do@workspace:packages/cache-do"],
638638

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"packageManager": "[email protected]",
1111
"overrides": {
1212
"@codemirror/state": "6.4.1",
13-
"@gitbook/api": "^0.118.0",
13+
"@gitbook/api": "^0.119.0",
1414
"react": "^19.0.0",
1515
"react-dom": "^19.0.0"
1616
},

packages/cache-tags/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"version": "0.3.1",
1212
"dependencies": {
13-
"@gitbook/api": "^0.118.0",
13+
"@gitbook/api": "^0.119.0",
1414
"assert-never": "^1.2.1"
1515
},
1616
"devDependencies": {

packages/gitbook-v2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.3.0",
44
"private": true,
55
"dependencies": {
6-
"@gitbook/api": "^0.118.0",
6+
"@gitbook/api": "^0.119.0",
77
"@gitbook/cache-tags": "workspace:*",
88
"@opennextjs/cloudflare": "1.1.0",
99
"@sindresorhus/fnv1a": "^3.1.0",

packages/gitbook/e2e/internal.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
CustomizationHeaderPreset,
66
CustomizationIconsStyle,
77
CustomizationSidebarListStyle,
8+
CustomizationThemeMode,
89
} from '@gitbook/api';
910
import { expect } from '@playwright/test';
1011
import jwt from 'jsonwebtoken';
@@ -681,6 +682,16 @@ const testCases: TestsCase[] = [
681682
url: 'page-options/page-with-cover',
682683
run: waitForCookiesDialog,
683684
},
685+
{
686+
name: 'With cover for dark mode',
687+
url: `page-options/page-with-dark-cover${getCustomizationURL({
688+
themes: {
689+
default: CustomizationThemeMode.Dark,
690+
toggeable: false,
691+
},
692+
})}`,
693+
run: waitForCookiesDialog,
694+
},
684695
{
685696
name: 'With hero cover',
686697
url: 'page-options/page-with-hero-cover',

packages/gitbook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"clean": "rm -rf ./.next && rm -rf ./public/~gitbook/static/icons && rm -rf ./public/~gitbook/static/math"
1717
},
1818
"dependencies": {
19-
"@gitbook/api": "^0.118.0",
19+
"@gitbook/api": "^0.119.0",
2020
"@gitbook/cache-do": "workspace:*",
2121
"@gitbook/cache-tags": "workspace:*",
2222
"@gitbook/colors": "workspace:*",

packages/gitbook/src/components/PageBody/PageCover.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export async function PageCover(props: {
2222
}) {
2323
const { as, page, cover, context } = props;
2424
const resolved = cover.ref ? await resolveContentRef(cover.ref, context) : null;
25+
const resolvedDark = cover.refDark ? await resolveContentRef(cover.refDark, context) : null;
2526

2627
return (
2728
<div
@@ -58,6 +59,12 @@ export async function PageCover(props: {
5859
height: defaultPageCover.height,
5960
},
6061
},
62+
dark: resolvedDark
63+
? {
64+
src: resolvedDark.href,
65+
size: resolvedDark.file?.dimensions,
66+
}
67+
: null,
6168
}}
6269
resize={
6370
// When using the default cover, we don't want to resize as it's a SVG

packages/react-contentkit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"dependencies": {
1212
"classnames": "^2.5.1",
13-
"@gitbook/api": "^0.118.0",
13+
"@gitbook/api": "^0.119.0",
1414
"@gitbook/icons": "workspace:*"
1515
},
1616
"peerDependencies": {

0 commit comments

Comments
 (0)