Skip to content

Commit

Permalink
fix: handle custom provider with iconifyOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Nov 7, 2023
1 parent fb36c48 commit c77bcef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/runtime/Icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const iconName = computed(() => {

return resolveIconName(name)
})
const iconKey = computed(() => `${iconName.value.prefix}:${iconName.value.name}`)
const iconKey = computed(() => [iconName.value.provider, iconName.value.prefix, iconName.value.name].filter(Boolean).join(':'))
const icon = computed<IconifyIcon | undefined>(() => state.value?.[iconKey.value])
const component = computed(() => nuxtApp.vueApp.component(props.name))
const sSize = computed(() => {
Expand All @@ -91,7 +91,7 @@ async function loadIconComponent () {
}
if (!state.value?.[iconKey.value]) {
isFetching.value = true
state.value[iconKey.value] = await loadIcon({ provider: '', ...iconName.value }).catch(() => undefined)
state.value[iconKey.value] = await loadIcon(iconName.value).catch(() => undefined)
isFetching.value = false
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/runtime/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// @ts-ignore
import iconCollections from '#icon-collections'

export function resolveIconName (name: string) {
export function resolveIconName (name: string = '') {
let prefix
let provider = ''

if (name[0] === '@' && name.includes(':')) {
provider = name.split(':')[0].slice(1)
name = name.split(':').slice(1).join(':')
}

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

return {
provider,
prefix: prefix || '',
name: name || ''
}
Expand Down

0 comments on commit c77bcef

Please sign in to comment.