Self-host homepage fonts to improve page load speed (#1370)

Co-authored-by: mundry <mundry@users.noreply.github.com>
This commit is contained in:
mundry 2021-09-14 23:21:40 +02:00 committed by GitHub
parent b6a75494b1
commit 32891fbe96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 52 additions and 5 deletions

View file

@ -34,8 +34,3 @@ const { title, description, image = 'https://astro.build/social.jpg?v=1', canoni
<meta property="twitter:title" content={title} />
<meta property="twitter:description" content={description} />
<meta property="twitter:image" content={image} />
<!-- Fonts -->
<link rel="dns-prefetch" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;700&family=IBM+Plex+Sans:wght@400;700&display=swap">

View file

@ -1,3 +1,4 @@
@use './fonts.scss';
@use './code.scss';
:root {

49
www/src/scss/fonts.scss Normal file
View file

@ -0,0 +1,49 @@
/* ibm-plex-sans-regular - latin */
@font-face {
font-family: 'IBM Plex Sans';
font-style: normal;
font-weight: 400;
src: local(''),
url('/assets/fonts/ibm-plex-sans/ibm-plex-sans-v9-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('/assets/fonts/ibm-plex-sans/ibm-plex-sans-v9-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* ibm-plex-sans-600 - latin */
@font-face {
font-family: 'IBM Plex Sans';
font-style: normal;
font-weight: 600;
src: local(''),
url('/assets/fonts/ibm-plex-sans/ibm-plex-sans-v9-latin-600.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('/assets/fonts/ibm-plex-sans/ibm-plex-sans-v9-latin-600.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* ibm-plex-sans-700 - latin */
@font-face {
font-family: 'IBM Plex Sans';
font-style: normal;
font-weight: 700;
src: local(''),
url('/assets/fonts/ibm-plex-sans/ibm-plex-sans-v9-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('/assets/fonts/ibm-plex-sans/ibm-plex-sans-v9-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* ibm-plex-mono-regular - latin */
@font-face {
font-family: 'IBM Plex Mono';
font-style: normal;
font-weight: 400;
src: local(''),
url('/assets/fonts/ibm-plex-mono/ibm-plex-mono-v7-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('/assets/fonts/ibm-plex-mono/ibm-plex-mono-v7-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* ibm-plex-mono-700 - latin */
@font-face {
font-family: 'IBM Plex Mono';
font-style: normal;
font-weight: 700;
src: local(''),
url('/assets/fonts/ibm-plex-mono/ibm-plex-mono-v7-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('/assets/fonts/ibm-plex-mono/ibm-plex-mono-v7-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}

View file

@ -1,3 +1,5 @@
@use './fonts.scss';
:root {
--font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
--font-mono: 'IBM Plex Mono', Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono',