Skip to content

Commit c77bcef

Browse files
committedNov 7, 2023
fix: handle custom provider with iconifyOptions
1 parent fb36c48 commit c77bcef

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed
 

‎src/runtime/Icon.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const iconName = computed(() => {
6767

6868
return resolveIconName(name)
6969
})
70-
const iconKey = computed(() => `${iconName.value.prefix}:${iconName.value.name}`)
70+
const iconKey = computed(() => [iconName.value.provider, iconName.value.prefix, iconName.value.name].filter(Boolean).join(':'))
7171
const icon = computed<IconifyIcon | undefined>(() => state.value?.[iconKey.value])
7272
const component = computed(() => nuxtApp.vueApp.component(props.name))
7373
const sSize = computed(() => {
@@ -91,7 +91,7 @@ async function loadIconComponent () {
9191
}
9292
if (!state.value?.[iconKey.value]) {
9393
isFetching.value = true
94-
state.value[iconKey.value] = await loadIcon({ provider: '', ...iconName.value }).catch(() => undefined)
94+
state.value[iconKey.value] = await loadIcon(iconName.value).catch(() => undefined)
9595
isFetching.value = false
9696
}
9797
}

‎src/runtime/utils/index.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
// @ts-ignore
22
import iconCollections from '#icon-collections'
33

4-
export function resolveIconName (name: string) {
4+
export function resolveIconName (name: string = '') {
55
let prefix
6+
let provider = ''
7+
8+
if (name[0] === '@' && name.includes(':')) {
9+
provider = name.split(':')[0].slice(1)
10+
name = name.split(':').slice(1).join(':')
11+
}
612

713
if (name.startsWith('i-')) {
814
name = name.replace(/^i-/, '')
@@ -22,6 +28,7 @@ export function resolveIconName (name: string) {
2228
}
2329

2430
return {
31+
provider,
2532
prefix: prefix || '',
2633
name: name || ''
2734
}

0 commit comments

Comments
 (0)
Please sign in to comment.