Skip to content

Commit

Permalink
fix(vite.config): mdi icon convert camelCase to kebab-case
Browse files Browse the repository at this point in the history
When the previous solution encounters mdiBattery80, it will be converted to mdi-battery-8-0.
When using mdi-battery-80, an error that the icon cannot be found will be prompted.
This solution first converts uppercase letters and then matches one or more numbers.
  • Loading branch information
kingyue737 committed Mar 21, 2024
1 parent da3e65b commit bd83846
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const mdi: Record<string, string> = {}
Object.keys(mdicons).forEach((key) => {
const value = (mdicons as Record<string, string>)[key]
mdi[
key.replace(
/[A-Z]+(?![a-z])|[A-Z0-9]/g,
($, ofs) => (ofs ? '-' : '') + $.toLowerCase(),
)
key
.replace(/([A-Z])/g, '-$1')
.toLowerCase()
.replace(/([0-9]+)/g, '-$1')
] = value
})

Expand Down

0 comments on commit bd83846

Please sign in to comment.