Skip to content

Commit 07b6e11

Browse files
fix: exported links typing
1 parent 6c14081 commit 07b6e11

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

client.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ declare module 'unfonts.css' {
44
}
55

66
declare module 'unplugin-fonts/head' {
7-
export const links: string[]
7+
import { HtmlTagDescriptor } from "vite"
8+
export const links: HtmlTagDescriptor[]
89
}

examples/astro/src/pages/index.astro

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
import Unfont from 'unplugin-fonts/astro/component.astro';
33
---
44

5-
<div>
6-
<Unfont />
7-
<h1>Hello Astro!</h1>
8-
<h2>I'm using a local font !</h2>
9-
<a href="https://vitejs.dev/guide/features.html" target="_blank">Documentation</a>
10-
</div>
5+
<html>
6+
<head>
7+
<Unfont />
8+
</head>
9+
<body>
10+
<h1>Hello Astro!</h1>
11+
<h2>I'm using a local font !</h2>
12+
<a href="https://vitejs.dev/guide/features.html" target="_blank">Documentation</a>
13+
</body>
14+
</html>
1115

1216
<style>
1317
body {

src/astro.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
1+
import type { AstroIntegration } from 'astro'
12
import type { Options } from './types'
23
import unplugin from '.'
3-
// import { getHeadLinkTags } from './loaders'
44

55
export default function (options: Options) {
6-
return {
6+
return <AstroIntegration>{
77
name: 'unplugin-fonts',
88
hooks: {
9-
'astro:config:setup': async (astro: any) => {
9+
'astro:config:setup': async (astro) => {
1010
if (options?.custom)
1111
options.custom.stripPrefix = 'public/'
1212

1313
astro.config.vite.plugins ||= []
1414
astro.config.vite.plugins.push(unplugin.vite(options))
1515

16-
// const links = getHeadLinkTags(options, astro.config.root.toString())
17-
// const linksString: string[] = []
18-
19-
// for (const link of links) {
20-
// linksString.push(`<link ${Object.entries(link.attrs || {}).map(([key, value]) => `${key}="${value}"`).join(' ')} />`)
21-
// }
22-
2316
astro.injectScript('page-ssr', 'import "unfonts.css";')
2417
},
2518
},

src/astro/component.astro

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
---
2-
import type { HtmlTagDescriptor } from 'vite'
3-
4-
// @ts-ignore
52
import { links } from 'unplugin-fonts/head'
63
---
74

85
<>
9-
{links.map((link: HtmlTagDescriptor) => {
6+
{links.map((link) => {
107
const attrs = link?.attrs || {}
118
return (
129
<link {...attrs} />
1310
)
1411
})}
15-
</>
12+
</>

0 commit comments

Comments
 (0)