Skip to content

Commit 736c95e

Browse files
committed
move google fonts to default
1 parent 958eb05 commit 736c95e

File tree

5 files changed

+219
-219
lines changed

5 files changed

+219
-219
lines changed

bun.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"packages/cache-tags": {
2626
"name": "@gitbook/cache-tags",
27-
"version": "0.1.0",
27+
"version": "0.2.0",
2828
"dependencies": {
2929
"@gitbook/api": "*",
3030
"assert-never": "^1.2.1",
@@ -49,7 +49,7 @@
4949
},
5050
"packages/gitbook": {
5151
"name": "gitbook",
52-
"version": "0.7.3",
52+
"version": "0.8.0",
5353
"dependencies": {
5454
"@gitbook/api": "*",
5555
"@gitbook/cache-do": "workspace:*",
@@ -133,7 +133,7 @@
133133
},
134134
"packages/gitbook-v2": {
135135
"name": "gitbook-v2",
136-
"version": "0.2.0",
136+
"version": "0.2.1",
137137
"dependencies": {
138138
"@gitbook/api": "*",
139139
"@gitbook/cache-tags": "workspace:*",
@@ -195,7 +195,7 @@
195195
},
196196
"packages/react-contentkit": {
197197
"name": "@gitbook/react-contentkit",
198-
"version": "0.6.2",
198+
"version": "0.7.0",
199199
"dependencies": {
200200
"@gitbook/api": "*",
201201
"@gitbook/icons": "workspace:*",
@@ -227,7 +227,7 @@
227227
},
228228
"packages/react-openapi": {
229229
"name": "@gitbook/react-openapi",
230-
"version": "1.1.3",
230+
"version": "1.1.4",
231231
"dependencies": {
232232
"@gitbook/openapi-parser": "workspace:*",
233233
"@scalar/api-client-react": "^1.1.36",

packages/gitbook/src/fonts/customFont.test.ts packages/gitbook/src/fonts/custom.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
type CustomizationFontDefinition,
55
generateFontFacesCSS,
66
getFontSourcesToPreload,
7-
} from './customFonts';
7+
} from './custom';
88

99
const TEST_FONTS = {
1010
basic: {

packages/gitbook/src/fonts/customFonts.ts packages/gitbook/src/fonts/custom.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { CustomizationDefaultFont } from '@gitbook/api';
2-
import { fonts } from './index';
2+
import { fonts } from './default';
33

44
/**
55
* The human-readable font-family name used in CSS (e.g., "Open Sans", "Playfair Display").
@@ -60,7 +60,7 @@ export type CustomizationFont = CustomizationDefaultFont | CustomizationFontDefi
6060
* Define the custom font faces and set the --font-content to the custom font name
6161
*/
6262
export function generateFontFacesCSS(customFont: CustomizationFontDefinition): string {
63-
const { fontFamily, fontFaces } = customFont;
63+
const { fontFaces } = customFont;
6464

6565
// Generate font face declarations for all weights
6666
const fontFaceDeclarations = fontFaces
@@ -79,7 +79,7 @@ export function generateFontFacesCSS(customFont: CustomizationFontDefinition): s
7979

8080
return `
8181
@font-face {
82-
font-family: ${fontFamily};
82+
font-family: CustomFont;
8383
font-style: normal;
8484
font-weight: ${face.weight};
8585
font-display: swap;
@@ -92,7 +92,7 @@ export function generateFontFacesCSS(customFont: CustomizationFontDefinition): s
9292
return `
9393
${fontFaceDeclarations}
9494
:root {
95-
--font-custom: ${fontFamily};
95+
--font-custom: CustomFont;
9696
}
9797
`;
9898
}

packages/gitbook/src/fonts/default.ts

+207
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
import { CustomizationDefaultFont } from '@gitbook/api';
2+
import {
3+
Fira_Sans_Extra_Condensed,
4+
IBM_Plex_Mono,
5+
IBM_Plex_Serif,
6+
Inter,
7+
Lato,
8+
Merriweather,
9+
Noto_Color_Emoji,
10+
Noto_Sans,
11+
Open_Sans,
12+
Overpass,
13+
Poppins,
14+
Raleway,
15+
Roboto,
16+
Roboto_Slab,
17+
Source_Sans_3,
18+
Ubuntu,
19+
} from 'next/font/google';
20+
import localFont from 'next/font/local';
21+
22+
export const fontNotoColorEmoji = Noto_Color_Emoji({
23+
variable: '--font-noto-color-emoji',
24+
weight: ['400'],
25+
preload: false,
26+
display: 'swap',
27+
});
28+
29+
/*
30+
Fonts are downloaded and loaded by next/font.
31+
32+
We can't use "preload: true" as otherwise Next will preload all the fonts on the page
33+
while spaces only use one font at a time.
34+
*/
35+
36+
const inter = Inter({
37+
weight: ['400', '500', '600', '700'],
38+
variable: '--font-content',
39+
preload: false,
40+
display: 'swap',
41+
fallback: ['system-ui', 'arial'],
42+
});
43+
44+
export const ibmPlexMono = IBM_Plex_Mono({
45+
weight: ['400', '500', '600', '700'],
46+
variable: '--font-mono',
47+
style: 'normal',
48+
display: 'swap',
49+
preload: false,
50+
fallback: ['monospace'],
51+
adjustFontFallback: false,
52+
});
53+
54+
const firaSans = Fira_Sans_Extra_Condensed({
55+
weight: ['400', '500', '600', '700'],
56+
variable: '--font-content',
57+
preload: false,
58+
display: 'swap',
59+
fallback: ['system-ui', 'arial'],
60+
});
61+
62+
const ibmPlexSerif = IBM_Plex_Serif({
63+
weight: ['400', '500', '600', '700'],
64+
variable: '--font-content',
65+
preload: false,
66+
display: 'swap',
67+
fallback: ['serif'],
68+
});
69+
70+
const lato = Lato({
71+
weight: ['400', '700', '900'],
72+
variable: '--font-content',
73+
preload: false,
74+
display: 'swap',
75+
fallback: ['system-ui', 'arial'],
76+
});
77+
78+
const merriweather = Merriweather({
79+
weight: ['400', '700', '900'],
80+
variable: '--font-content',
81+
preload: false,
82+
display: 'swap',
83+
fallback: ['serif'],
84+
});
85+
86+
const notoSans = Noto_Sans({
87+
weight: ['400', '500', '600', '700'],
88+
variable: '--font-content',
89+
preload: false,
90+
display: 'swap',
91+
fallback: ['system-ui', 'arial'],
92+
});
93+
94+
const openSans = Open_Sans({
95+
weight: ['400', '500', '600', '700'],
96+
variable: '--font-content',
97+
preload: false,
98+
display: 'swap',
99+
fallback: ['system-ui', 'arial'],
100+
});
101+
102+
const overpass = Overpass({
103+
weight: ['400', '500', '600', '700'],
104+
variable: '--font-content',
105+
preload: false,
106+
display: 'swap',
107+
fallback: ['system-ui', 'arial'],
108+
});
109+
110+
const poppins = Poppins({
111+
weight: ['400', '500', '600', '700'],
112+
variable: '--font-content',
113+
preload: false,
114+
display: 'swap',
115+
fallback: ['system-ui', 'arial'],
116+
});
117+
118+
const raleway = Raleway({
119+
weight: ['400', '500', '600', '700'],
120+
variable: '--font-content',
121+
preload: false,
122+
display: 'swap',
123+
fallback: ['system-ui', 'arial'],
124+
});
125+
126+
const roboto = Roboto({
127+
weight: ['400', '500', '700'],
128+
variable: '--font-content',
129+
preload: false,
130+
display: 'swap',
131+
fallback: ['system-ui', 'arial'],
132+
});
133+
134+
const robotoSlab = Roboto_Slab({
135+
weight: ['400', '500', '600', '700'],
136+
variable: '--font-content',
137+
preload: false,
138+
display: 'swap',
139+
fallback: ['system-ui', 'arial'],
140+
});
141+
142+
const sourceSansPro = Source_Sans_3({
143+
weight: ['400', '500', '600', '700'],
144+
variable: '--font-content',
145+
preload: false,
146+
display: 'swap',
147+
fallback: ['system-ui', 'arial'],
148+
});
149+
150+
const ubuntu = Ubuntu({
151+
weight: ['400', '500', '700'],
152+
variable: '--font-content',
153+
preload: false,
154+
display: 'swap',
155+
fallback: ['system-ui', 'arial'],
156+
});
157+
158+
const abcFavorit = localFont({
159+
variable: '--font-content',
160+
preload: false,
161+
display: 'swap',
162+
fallback: ['system-ui', 'arial'],
163+
src: [
164+
{
165+
path: './ABCFavorit/ABCFavorit-Variable.woff2',
166+
weight: '400 700',
167+
style: 'normal',
168+
},
169+
{
170+
path: './ABCFavorit/ABCFavorit-BoldItalic.woff2',
171+
weight: '700',
172+
style: 'italic',
173+
},
174+
{
175+
path: './ABCFavorit/ABCFavorit-MediumItalic.woff2',
176+
weight: '500',
177+
style: 'italic',
178+
},
179+
{
180+
path: './ABCFavorit/ABCFavorit-RegularItalic.woff2',
181+
weight: '400',
182+
style: 'italic',
183+
},
184+
],
185+
declarations: [{ prop: 'ascent-override', value: '100%' }],
186+
});
187+
188+
/**
189+
* Font definitions.
190+
*/
191+
export const fonts: { [fontName in CustomizationDefaultFont]: { variable: string } } = {
192+
[CustomizationDefaultFont.Inter]: inter,
193+
[CustomizationDefaultFont.FiraSans]: firaSans,
194+
[CustomizationDefaultFont.IBMPlexSerif]: ibmPlexSerif,
195+
[CustomizationDefaultFont.Lato]: lato,
196+
[CustomizationDefaultFont.Merriweather]: merriweather,
197+
[CustomizationDefaultFont.NotoSans]: notoSans,
198+
[CustomizationDefaultFont.OpenSans]: openSans,
199+
[CustomizationDefaultFont.Overpass]: overpass,
200+
[CustomizationDefaultFont.Poppins]: poppins,
201+
[CustomizationDefaultFont.Raleway]: raleway,
202+
[CustomizationDefaultFont.Roboto]: roboto,
203+
[CustomizationDefaultFont.RobotoSlab]: robotoSlab,
204+
[CustomizationDefaultFont.SourceSansPro]: sourceSansPro,
205+
[CustomizationDefaultFont.Ubuntu]: ubuntu,
206+
[CustomizationDefaultFont.ABCFavorit]: abcFavorit,
207+
};

0 commit comments

Comments
 (0)