Skip to content

Commit 41eb6f3

Browse files
committed
improve font loading
1 parent 4dd42ef commit 41eb6f3

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": ["react-app"],
2+
"extends": "eslint:recommended",
33
"rules": {
44
"max-len": [2, 120],
55
"semi": [1, "never"],

lib/layout.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from "react";
2-
import { injectGlobal } from "emotion";
3-
import { ThemeProvider } from "emotion-theming";
4-
import theme from "../common/theme";
1+
import React from 'react'
2+
import { injectGlobal } from 'emotion'
3+
import { ThemeProvider } from 'emotion-theming'
4+
import theme from '../common/theme'
55

66
// Add global styles
77
injectGlobal`
@@ -21,6 +21,7 @@ injectGlobal`
2121
*/
2222
html {
2323
font-family: 'Rubik', sans-serif;
24+
font-display: swap;
2425
box-sizing: border-box;
2526
}
2627
body{
@@ -295,16 +296,6 @@ injectGlobal`
295296
background: #fff url('./ajax-loader.gif') center center no-repeat;
296297
}
297298
298-
/* Icons */
299-
@font-face
300-
{
301-
font-family: 'slick';
302-
font-weight: normal;
303-
font-style: normal;
304-
305-
src: url('./fonts/slick.eot');
306-
src: url('./fonts/slick.eot?#iefix') format('embedded-opentype'), url('./fonts/slick.woff') format('woff'), url('./fonts/slick.ttf') format('truetype'), url('./fonts/slick.svg#slick') format('svg');
307-
}
308299
/* Arrows */
309300
.slick-prev,
310301
.slick-next
@@ -492,10 +483,10 @@ injectGlobal`
492483
opacity: .75;
493484
color: black;
494485
}
495-
`;
486+
`
496487

497488
export default ({ children }) => (
498489
<ThemeProvider theme={theme}>
499490
<div>{children}</div>
500491
</ThemeProvider>
501-
);
492+
)

pages/_document.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,30 @@ export default class FSDocument extends Document {
4444
<link rel="mask-icon" href="/static/favicons/safari-pinned-tab.svg" color="#4ea4f2" />
4545
<link rel="shortcut icon" href="/static/favicons/favicon.ico" />
4646
<link rel="manifest" href="/static/manifest.json" />
47-
<link href="https://fonts.googleapis.com/css?family=Rubik:300,400,500,700" rel="stylesheet" />
47+
48+
<link rel="preconnect" href="https://vars.hotjar.com" />
49+
<link rel="preconnect" href="https://js.intercomcdn.com" />
4850

4951
<style dangerouslySetInnerHTML={{ __html: this.props.css }} />
5052
</Head>
5153
<body>
5254
<Main />
5355
<NextScript />
5456

57+
{/* webfont loader */}
58+
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js" />
59+
<script
60+
dangerouslySetInnerHTML={{
61+
__html: `
62+
WebFont.load({
63+
google: {
64+
families: ['Rubik:300', 'Rubik:400', 'Rubik:500', 'Rubik:700']
65+
}
66+
});
67+
`,
68+
}}
69+
/>
70+
5571
{/* Intercom */}
5672
<script
5773
async

server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file doesn't go through babel or webpack transformation.
22
// Make sure the syntax and sources this file requires are compatible with the current node version you are running
33
// See https://github.com/zeit/next.js/issues/1245 for discussions on Universal Webpack or universal Babel
4-
const { createServer } = require('https')
4+
55
const { parse } = require('url')
66
const { join } = require('path')
77
const next = require('next')
@@ -10,6 +10,8 @@ const dev = process.env.NODE_ENV !== 'production'
1010
const app = next({ dev })
1111
const handle = app.getRequestHandler()
1212

13+
const { createServer } = dev ? require('http') : require('https')
14+
1315
app.prepare().then(() => {
1416
createServer((req, res) => {
1517
// Be sure to pass `true` as the second argument to `url.parse`.

0 commit comments

Comments
 (0)