Skip to content

Commit 41218fa

Browse files
harukatsnatemoo-re
andauthored
fix: include aliases in icon type definitions and hash calculation (#250)
* fix: include aliases in icon type definitions and hash calculation * add changeset * Update .changeset/chilled-fans-beg.md --------- Co-authored-by: Nate Moore <[email protected]>
1 parent 1e6d429 commit 41218fa

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

.changeset/chilled-fans-beg.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"astro-icon": patch
3+
---
4+
5+
Fixes type definitions and hash calculation for aliased icon names

packages/core/src/vite-plugin-astro-icon.ts

+16-9
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,16 @@ declare module 'virtual:astro-icon' {
106106
collections.length > 0
107107
? collections
108108
.map((collection) =>
109-
Object.keys(collection.icons).map(
110-
(icon) =>
111-
`\n\t\t| "${
112-
collection.prefix === defaultPack
113-
? ""
114-
: `${collection.prefix}:`
115-
}${icon}"`,
116-
),
109+
Object.keys(collection.icons)
110+
.concat(Object.keys(collection.aliases ?? {}))
111+
.map(
112+
(icon) =>
113+
`\n\t\t| "${
114+
collection.prefix === defaultPack
115+
? ""
116+
: `${collection.prefix}:`
117+
}${icon}"`,
118+
),
117119
)
118120
.flat(1)
119121
.join("")
@@ -127,7 +129,12 @@ function collectionsHash(collections: IconCollection[]): string {
127129
const hash = createHash("sha256");
128130
for (const collection of collections) {
129131
hash.update(collection.prefix);
130-
hash.update(Object.keys(collection.icons).sort().join(","));
132+
hash.update(
133+
Object.keys(collection.icons)
134+
.concat(Object.keys(collection.aliases ?? {}))
135+
.sort()
136+
.join(","),
137+
);
131138
}
132139
return hash.digest("hex");
133140
}

0 commit comments

Comments
 (0)