Skip to content

Commit cab68fb

Browse files
committed
feat(fonts): Prioritize woff2
1 parent eacdd5c commit cab68fb

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

packages/gamut-styles/src/AssetProvider.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { webFonts } from './remoteAssets/fonts';
22

33
export const createFontLinks = () =>
4-
webFonts.flatMap(({ filePath, extensions }) =>
5-
extensions.map((ext) => (
4+
webFonts
5+
.filter((f) => f.extensions.includes('woff2'))
6+
.map(({ filePath }) => (
67
<link
7-
key={`${filePath}-${ext}`}
8+
key={filePath}
89
rel="preload"
9-
href={`${filePath}.${ext}`}
10+
href={`${filePath}.woff2`}
1011
crossOrigin="anonymous"
1112
as="font"
12-
type={`font/${ext}`}
13+
type="font/woff2"
1314
/>
14-
))
15-
);
15+
));
1616

1717
export const AssetProvider = () => {
1818
return <>{createFontLinks()}</>;

packages/gamut-styles/src/remoteAssets/fonts.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@ export const FONT_ASSET_PATH = `https://www.codecademy.com/gamut`;
33
export const webFonts = [
44
{
55
filePath: `${FONT_ASSET_PATH}/apercu-regular-pro`,
6-
extensions: ['woff', 'woff2'],
6+
extensions: ['woff2', 'woff'],
77
name: 'Apercu',
88
},
99
{
1010
filePath: `${FONT_ASSET_PATH}/apercu-italic-pro`,
11-
extensions: ['woff', 'woff2'],
11+
extensions: ['woff2', 'woff'],
1212
name: 'Apercu',
1313
style: 'italic',
1414
},
1515
{
1616
filePath: `${FONT_ASSET_PATH}/apercu-bold-pro`,
17-
extensions: ['woff', 'woff2'],
17+
extensions: ['woff2', 'woff'],
1818
name: 'Apercu',
1919
weight: 'bold',
2020
},
2121
{
2222
filePath: `${FONT_ASSET_PATH}/apercu-bold-italic-pro`,
23-
extensions: ['woff', 'woff2'],
23+
extensions: ['woff2', 'woff'],
2424
name: 'Apercu',
2525
weight: 'bold',
2626
style: 'italic',
2727
},
2828
{
2929
filePath: `${FONT_ASSET_PATH}/SuisseIntlMono-Bold-WebS`,
30-
extensions: ['woff', 'woff2'],
30+
extensions: ['woff2', 'woff'],
3131
name: 'Suisse',
3232
weight: 'bold',
3333
},
3434
{
3535
filePath: `${FONT_ASSET_PATH}/SuisseIntlMono-Regular-WebS`,
36-
extensions: ['woff', 'woff2'],
36+
extensions: ['woff2', 'woff'],
3737
name: 'Suisse',
3838
},
3939
];

0 commit comments

Comments
 (0)