Skip to content

Commit 80f6dca

Browse files
eteplusantfu
andauthoredNov 14, 2024··
feat(bundle-client): add support for no-prefix icon collections (#297)
Co-authored-by: Anthony Fu <github@antfu.me>
1 parent 36e38c3 commit 80f6dca

File tree

5 files changed

+39
-1
lines changed

5 files changed

+39
-1
lines changed
 

‎playground/components/ShowcaseFixture.vue

+9
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ defineProps<{
7878
:customize
7979
/>
8080
</p>
81+
<p>
82+
Custom icons with `prefix: ''` from local fs:
83+
<Icon
84+
name="nuxt-v3"
85+
size="64"
86+
:mode
87+
:customize
88+
/>
89+
</p>
8190
<p>
8291
Custom icons from layer:
8392
<Icon
+3
Loading

‎playground/nuxt.config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export default defineNuxtConfig({
4141
prefix: 'custom1',
4242
dir: './icons/custom1',
4343
},
44+
{
45+
prefix: '',
46+
dir: './icons/no-prefix',
47+
},
4448
],
4549
serverBundle: 'remote',
4650
fallbackToApi: 'server-only',

‎playground/test/nuxt/output/fixtures.html

+22
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,28 @@
205205
</g>
206206
</svg>
207207
</p>
208+
<p>
209+
Custom icons with `prefix: ''` from local fs:
210+
<svg
211+
xmlns="http://www.w3.org/2000/svg"
212+
xmlns:xlink="http://www.w3.org/1999/xlink"
213+
aria-hidden="true"
214+
role="img"
215+
ssr="true"
216+
class="iconify iconify--nuxt"
217+
style="font-size: 64px"
218+
width="1em"
219+
height="1em"
220+
viewBox="0 0 512 512"
221+
>
222+
<g fill="none">
223+
<path
224+
d="M281.44 397.667H438.32C443.326 397.667 448.118 395.908 452.453 393.427C456.789 390.946 461.258 387.831 463.76 383.533C466.262 379.236 468.002 374.36 468 369.399C467.998 364.437 466.266 359.563 463.76 355.268L357.76 172.947C355.258 168.65 352.201 165.534 347.867 163.053C343.532 160.573 337.325 158.813 332.32 158.813C327.315 158.813 322.521 160.573 318.187 163.053C313.852 165.534 310.795 168.65 308.293 172.947L281.44 219.587L227.733 129.13C225.229 124.834 222.176 120.307 217.84 117.827C213.504 115.346 208.713 115 203.707 115C198.701 115 193.909 115.346 189.573 117.827C185.238 120.307 180.771 124.834 178.267 129.13L46.8267 355.268C44.3208 359.563 44.0022 364.437 44 369.399C43.9978 374.36 44.3246 379.235 46.8267 383.533C49.3288 387.83 53.7979 390.946 58.1333 393.427C62.4688 395.908 67.2603 397.667 72.2667 397.667H171.2C210.401 397.667 238.934 380.082 258.827 346.787L306.88 263.4L332.32 219.587L410.053 352.44H306.88L281.44 397.667ZM169.787 352.44H100.533L203.707 174.36L256 263.4L221.361 323.784C208.151 345.387 193.089 352.44 169.787 352.44Z"
225+
fill="#00DC82"
226+
></path>
227+
</g>
228+
</svg>
229+
</p>
208230
<p>
209231
Custom icons from layer:
210232
<svg

‎src/bundle-client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function registerClientBundle(
5151
` const collections = ${collectionsRaw}`,
5252
` for (const collection of collections) {`,
5353
` for (const [name, data] of Object.entries(collection.icons)) {`,
54-
` addIcon(collection.prefix + ':' + name, data)`,
54+
` addIcon(collection.prefix ? (collection.prefix + ':' + name) : name, data)`,
5555
` }`,
5656
' }',
5757
' _initialized = true',

0 commit comments

Comments
 (0)
Please sign in to comment.