File tree Expand file tree Collapse file tree 4 files changed +17
-22
lines changed Expand file tree Collapse file tree 4 files changed +17
-22
lines changed Original file line number Diff line number Diff line change @@ -4,5 +4,6 @@ declare module 'unfonts.css' {
4
4
}
5
5
6
6
declare module 'unplugin-fonts/head' {
7
- export const links : string [ ]
7
+ import { HtmlTagDescriptor } from "vite"
8
+ export const links : HtmlTagDescriptor [ ]
8
9
}
Original file line number Diff line number Diff line change 2
2
import Unfont from ' unplugin-fonts/astro/component.astro' ;
3
3
---
4
4
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 >
11
15
12
16
<style >
13
17
body {
Original file line number Diff line number Diff line change
1
+ import type { AstroIntegration } from 'astro'
1
2
import type { Options } from './types'
2
3
import unplugin from '.'
3
- // import { getHeadLinkTags } from './loaders'
4
4
5
5
export default function ( options : Options ) {
6
- return {
6
+ return < AstroIntegration > {
7
7
name : 'unplugin-fonts' ,
8
8
hooks : {
9
- 'astro:config:setup' : async ( astro : any ) => {
9
+ 'astro:config:setup' : async ( astro ) => {
10
10
if ( options ?. custom )
11
11
options . custom . stripPrefix = 'public/'
12
12
13
13
astro . config . vite . plugins ||= [ ]
14
14
astro . config . vite . plugins . push ( unplugin . vite ( options ) )
15
15
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
-
23
16
astro . injectScript ( 'page-ssr' , 'import "unfonts.css";' )
24
17
} ,
25
18
} ,
Original file line number Diff line number Diff line change 1
1
---
2
- import type { HtmlTagDescriptor } from ' vite'
3
-
4
- // @ts-ignore
5
2
import { links } from ' unplugin-fonts/head'
6
3
---
7
4
8
5
<>
9
- { links .map ((link : HtmlTagDescriptor ) => {
6
+ { links .map ((link ) => {
10
7
const attrs = link ?.attrs || {}
11
8
return (
12
9
<link { ... attrs } />
13
10
)
14
11
})}
15
- </>
12
+ </>
You can’t perform that action at this time.
0 commit comments