Skip to content

Commit

Permalink
Self-host fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaGanchev committed Sep 19, 2023
1 parent 1c363c3 commit d8fe123
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
},
"type": "module",
"dependencies": {
"@fontsource-variable/roboto-flex": "^5.0.8",
"@fontsource/alegreya": "^5.0.8",
"@fontsource/roboto": "^5.0.8",
"@urql/svelte": "^4.0.1",
"expr-eval": "^2.0.2",
"fuse.js": "^6.6.2",
Expand Down
31 changes: 12 additions & 19 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,19 @@
export let data;
let loaded = false;
onMount(() => {
loaded = true
import('@fontsource/roboto/100.css');
import('@fontsource/roboto/300.css');
import('@fontsource/roboto/400.css');
import('@fontsource/roboto/500.css');
import('@fontsource/roboto/100-italic.css');
import('@fontsource/roboto/300-italic.css');
import('@fontsource/roboto/400-italic.css');
import('@fontsource/roboto/500-italic.css');
import('@fontsource-variable/roboto-flex/opsz.css');
import('@fontsource/alegreya/400.css');
import('@fontsource/alegreya/500.css');
import('@fontsource/alegreya/700.css');
})
seoInfo.set({
Expand Down Expand Up @@ -70,22 +79,6 @@
</script>

<svelte:head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
{#if loaded}
<link
href="https://fonts.googleapis.com/css2?family=Alegreya:wght@400;500;700&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght,[email protected],400,45;8..144,400,50;8..144,1000,0&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700&display=swap"
rel="stylesheet"
/>
{/if}
{#each data.MainInfo.favicons as favicon}
<link rel="icon" type="image/png" sizes="{favicon.size}"
href={env.PUBLIC_SERVER_URL + favicon.favicon.url} />
Expand Down

0 comments on commit d8fe123

Please sign in to comment.