Skip to content

Commit 5881d7c

Browse files
fix: link filter types
1 parent 0b3fc3b commit 5881d7c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createUnplugin } from 'unplugin'
55
import { getHeadLinkTags } from './loaders'
66
import { customVirtualModule } from './loaders/custom'
77
import { fontsourceImports, fontsourceVirtualModule } from './loaders/fontsource'
8+
import { HtmlTagDescriptor } from 'vite'
89

910
const virtualStylesId = 'unfonts.css'
1011
const resolvedVirtualStylesId = `\0${virtualStylesId}`
@@ -109,7 +110,7 @@ export default createUnplugin<Options | undefined>((userOptions) => {
109110
}
110111
let tagsReturned = tags
111112
if (options?.custom?.linkFilter) {
112-
const newTags: object[] | boolean = options?.custom?.linkFilter(tags)
113+
const newTags = options?.custom?.linkFilter(tags)
113114
if (Array.isArray(newTags)) {
114115
tagsReturned = newTags
115116
} else {
@@ -160,7 +161,7 @@ function generateVitepressBundle(
160161

161162
let tagsReturned = tags
162163
if (options?.custom?.linkFilter) {
163-
const newTags: object[] | boolean = options?.custom?.linkFilter(tags)
164+
const newTags = options?.custom?.linkFilter(tags)
164165
if (Array.isArray(newTags)) {
165166
tagsReturned = newTags
166167
} else {

src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { HtmlTagDescriptor } from "vite"
2+
13
export interface Options {
24
custom?: CustomFonts
35
fontsource?: FontsourceFonts
@@ -102,7 +104,7 @@ export interface CustomFonts {
102104
* generated.
103105
* @default true
104106
*/
105-
linkFilter?: (tags: object[]) => object[] | boolean
107+
linkFilter?: (tags: HtmlTagDescriptor[]) => HtmlTagDescriptor[] | boolean
106108

107109
/**
108110
* @default: 'head-prepend'

0 commit comments

Comments
 (0)