forked from transitive-bullshit/nextjs-notion-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomFont.tsx
34 lines (30 loc) · 1.04 KB
/
CustomFont.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Head from 'next/head'
import * as React from 'react'
import * as types from '../lib/types'
export const CustomFont: React.FC<{ site: types.Site }> = ({ site }) => {
if (!site.fontFamily) {
return null
}
// https://developers.google.com/fonts/docs/css2
const fontFamilies = [site.fontFamily]
const googleFontFamilies = fontFamilies
.map((font) => font.replace(/ /g, '+'))
.map((font) => `family=${font}:ital,wght@0,200..700;1,200..700`)
.join('&')
const googleFontsLink = `https://fonts.googleapis.com/css?${googleFontFamilies}&display=swap`
const cssFontFamilies = fontFamilies.map((font) => `"${font}"`).join(', ')
return (
<>
<Head>
<link rel='stylesheet' href={googleFontsLink} />
<style>{`
.notion.notion-app {
font-family: ${cssFontFamilies}, -apple-system, BlinkMacSystemFont,
'Segoe UI', Helvetica, 'Apple Color Emoji', Arial, sans-serif,
'Segoe UI Emoji', 'Segoe UI Symbol';
}
`}</style>
</Head>
</>
)
}