Skip to content

Commit

Permalink
fix: find collection properly when icon component includes : (#320)
Browse files Browse the repository at this point in the history
* fix: find collection properly when icon includes `:`

* chore: cleanup
  • Loading branch information
userquin authored Nov 2, 2023
1 parent 731906f commit 65b6d41
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions examples/vite-vue3/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import RawMdiAlarmOff3 from 'virtual:icons/mdi/alarm-off?raw&width=unset&height=
<i-mdi:light-flood-down />
<i-mdi-account />
<i-fa-solid-dice-five />
<i-heroicons-outline:menu-alt-2 />
<i-heroicons-outline-menu-alt-2 />
<i-ri-apps-2-line />
<i-mdi-dice-d12 />
Expand Down
2 changes: 1 addition & 1 deletion examples/vite-vue3/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ declare module 'vue' {
ICustomCarA: typeof import('~icons/custom/car-a')['default']
ICustomSteeringWheel: typeof import('~icons/custom/steering-wheel')['default']
IFaSolidDiceFive: typeof import('~icons/fa-solid/dice-five')['default']
'IHeroiconsOutline:menuAlt2': typeof import('~icons/heroicons-outline/menu-alt2')['default']
IHeroiconsOutlineMenuAlt2: typeof import('~icons/heroicons-outline/menu-alt2')['default']
IIconParkAbnormal: typeof import('~icons/icon-park/abnormal')['default']
IIcTwotone23mp: typeof import('~icons/ic/twotone23mp')['default']
Expand All @@ -23,7 +24,6 @@ declare module 'vue' {
IMdiAccount: typeof import('~icons/mdi/account')['default']
IMdiDiceD12: typeof import('~icons/mdi/dice-d12')['default']
IMdiLightAlarm: typeof import('~icons/mdi-light/alarm')['default']
IMdiLightFloodDown: typeof import('~icons/mdi-light/flood-down')['default']
INotoV1FlagForFlagJapan: typeof import('~icons/noto-v1/flag-for-flag-japan')['default']
IParkAbnormal: typeof import('~icons/icon-park/abnormal')['default']
IRiApps2Line: typeof import('~icons/ri/apps2-line')['default']
Expand Down
10 changes: 5 additions & 5 deletions src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,14 @@ export default function ComponentsResolver(options: ComponentResolverOption = {}
return

const slice = collection.slice(prefix.length)
const resolvedCollection = collections.find(i => slice.startsWith(`${i}-`)) || collections.find(i => slice.startsWith(i))
// find the collection
const resolvedCollection = collections.find(i => slice === i)
if (!resolvedCollection)
return

collection = resolvedCollection

icon = camelToKebab(iconSuffix)
if (icon[0] === '-')
icon = icon.slice(1)
}
else {
const kebab = camelToKebab(name)
Expand All @@ -108,10 +107,11 @@ export default function ComponentsResolver(options: ComponentResolverOption = {}

collection = resolvedCollection
icon = slice.slice(resolvedCollection.length)
if (icon[0] === '-')
icon = icon.slice(1)
}

if (icon[0] === '-')
icon = icon.slice(1)

if (!icon)
return

Expand Down

0 comments on commit 65b6d41

Please sign in to comment.