Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Font not loading in Sveltekit #41

Open
Maggi64 opened this issue Mar 20, 2023 · 3 comments
Open

[Bug]: Font not loading in Sveltekit #41

Maggi64 opened this issue Mar 20, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@Maggi64
Copy link
Contributor

Maggi64 commented Mar 20, 2023

Demo URL

https://stackblitz.com/edit/sveltejs-kit-template-default-yh1zpq?file=jsconfig.json

What happened?

Thank you for this cool lib :)

I couldn't get it to work on sveltekit. I think configured everything correctly, but the font still won't load.

Reproduction steps

1. Open Stackblitz
2. npm run dev
3. font isn't loaded/applied

Relevant log output

No response

What browsers are you seeing the problem on?

No response

What is your operating system?

No response

@Maggi64 Maggi64 added the bug Something isn't working label Mar 20, 2023
@cssninjastudio
Copy link

Hello @Maggi64! Thanks for opening this issue, we will get back to you soon!
Until then, feel free to join us on discord

If you love our work, please consider sponsoring us

@stafyniaksacha
Copy link
Member

Hello @Maggi64!

I've found that I can not inject head tags via the vite plugin (this is related to sveltekit not using transformIndexHtml vite process)

So, similarly to astro, we have to manually inject links to the template:

<script>
  import { links } from 'unplugin-fonts/head'
</script>

<svelte:head>
  {#each links as link}
    <link {...link?.attrs || {}} />
  {/each}
</svelte:head>

I can export a simple component like I did for astro here: https://github.com/cssninjaStudio/unplugin-fonts/blob/main/src/astro/component.astro

What do you think?

@Maggi64
Copy link
Contributor Author

Maggi64 commented Mar 22, 2023

@stafyniaksacha sounds good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants