Skip to content

Commit fa91eb7

Browse files
authored
Fix dark mode PDF (#3065)
1 parent c756761 commit fa91eb7

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

.changeset/selfish-rules-yell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Fix PDF generation when user has dark mode configured.

packages/gitbook/src/components/DocumentView/Tabs/Tabs.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ export function Tabs(props: BlockProps<DocumentBlockTabs>) {
1212
const tabs: TabsItem[] = [];
1313
const tabsBody: React.ReactNode[] = [];
1414

15-
block.nodes.forEach((tab) => {
15+
block.nodes.forEach((tab, index) => {
1616
tabs.push({
1717
id: tab.meta?.id ?? tab.key!,
1818
title: tab.data.title ?? '',
1919
});
2020

2121
tabsBody.push(
2222
<Blocks
23+
key={tab.key ?? index}
2324
nodes={tab.nodes}
2425
document={document}
2526
ancestorBlocks={[...ancestorBlocks, block, tab]}

packages/gitbook/src/components/PDF/PDFRootLayout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CustomizationRootLayout } from '@/components/RootLayout';
22
import { defaultCustomization } from '@/lib/utils';
3+
import { CustomizationThemeMode } from '@gitbook/api';
34
import type { GitBookSiteContext, GitBookSpaceContext } from '@v2/lib/context';
45

56
/**
@@ -16,6 +17,7 @@ export async function PDFRootLayout(props: {
1617
customization={
1718
'customization' in context ? context.customization : defaultCustomization()
1819
}
20+
forcedTheme={CustomizationThemeMode.Light}
1921
>
2022
{children}
2123
</CustomizationRootLayout>

0 commit comments

Comments
 (0)