Skip to content

Commit f9f5ba1

Browse files
svifty7antfu
andauthored
feat: scan nested subfolders for custom collections (#407)
Co-authored-by: Anthony Fu <github@antfu.me>
1 parent 96badc5 commit f9f5ba1

File tree

12 files changed

+246
-10
lines changed

12 files changed

+246
-10
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ export default defineNuxtConfig({
165165
customCollections: [
166166
{
167167
prefix: 'my-icon',
168-
dir: './assets/my-icons'
168+
dir: './assets/my-icons',
169+
// if you want to include all the icons in nested directories:
170+
// recursive: true,
169171
},
170172
],
171173
},

playground/components/ShowcaseFixture.vue

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,45 @@ defineProps<{
9090
:customize
9191
/>
9292
</p>
93+
<p>
94+
Custom icons with nested subfolders from local fs:
95+
<Icon
96+
name="nested:nuxt-v1"
97+
size="32"
98+
:mode
99+
:customize
100+
/>
101+
<Icon
102+
name="i-nested-nuxt-v2"
103+
size="32"
104+
:mode
105+
:customize
106+
/>
107+
<Icon
108+
name="i-nested-nuxt-v3"
109+
size="32"
110+
:mode
111+
:customize
112+
/>
113+
<Icon
114+
name="i-nested-nuxt-v3-beta"
115+
size="32"
116+
:mode
117+
:customize
118+
/>
119+
<Icon
120+
name="nested:subfolder-Foo.BarZag"
121+
size="32"
122+
:mode
123+
:customize
124+
/>
125+
<Icon
126+
name="nested:subfolder-Foo_Bar_Zag"
127+
size="32"
128+
:mode
129+
:customize
130+
/>
131+
</p>
93132
<p>
94133
Custom icons with `prefix: ''` from local fs:
95134
<Icon
Lines changed: 8 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 8 additions & 0 deletions
Loading
Lines changed: 8 additions & 0 deletions
Loading

playground/nuxt.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ export default defineNuxtConfig({
5252
dir: './icons/no-prefix',
5353
normalizeIconName: false,
5454
},
55+
{
56+
prefix: 'nested',
57+
dir: './icons/nesting',
58+
normalizeIconName: false,
59+
recursive: true,
60+
},
5561
{
5662
prefix: 'json-collection',
5763
icons: {

playground/test/nuxt/output/fixtures.html

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,150 @@
248248
</g>
249249
</svg>
250250
</p>
251+
<p>
252+
Custom icons with nested subfolders from local fs:
253+
<svg
254+
xmlns="http://www.w3.org/2000/svg"
255+
xmlns:xlink="http://www.w3.org/1999/xlink"
256+
aria-hidden="true"
257+
role="img"
258+
class="iconify iconify--nested"
259+
style="font-size: 32px"
260+
width="1.36em"
261+
height="1em"
262+
viewBox="0 0 256 189"
263+
>
264+
<g>
265+
<polygon
266+
fill="#48B884"
267+
points="109.7766 0.0009 -0.0004 188.2259 219.5526 188.2259"
268+
></polygon>
269+
<polygon
270+
fill="#3F7F70"
271+
points="72.8361 188.226 255.9991 188.226 164.4181 31.198"
272+
></polygon>
273+
<polygon
274+
fill="#36495D"
275+
points="72.8361 188.226 219.5521 188.226 146.1941 62.444"
276+
></polygon>
277+
</g></svg
278+
><svg
279+
xmlns="http://www.w3.org/2000/svg"
280+
xmlns:xlink="http://www.w3.org/1999/xlink"
281+
aria-hidden="true"
282+
role="img"
283+
class="iconify iconify--nested"
284+
style="font-size: 32px"
285+
width="1.35em"
286+
height="1em"
287+
viewBox="0 0 400 298"
288+
>
289+
<g fill="none" fill-rule="nonzero">
290+
<path
291+
fill="#00C58E"
292+
d="M227.92099 82.07407l-13.6889 23.7037-46.8148-81.08641L23.7037 273.58025h97.3037c0 13.0912 10.61252 23.7037 23.70371 23.7037H23.70371c-8.46771 0-16.29145-4.52017-20.5246-11.85382-4.23315-7.33366-4.23272-16.36849.00114-23.70174L146.89383 12.83951c4.23415-7.33433 12.0596-11.85252 20.5284-11.85252 8.46878 0 16.29423 4.51819 20.52839 11.85252l39.97037 69.23456z"
293+
></path>
294+
<path
295+
fill="#2F495E"
296+
d="M331.6642 261.7284l-90.05432-155.95062-13.6889-23.7037-13.68888 23.7037-90.04445 155.95061c-4.23385 7.33325-4.23428 16.36808-.00113 23.70174 4.23314 7.33365 12.05689 11.85382 20.5246 11.85382h166.4c8.46946 0 16.29644-4.51525 20.532-11.84955 4.23555-7.3343 4.23606-16.37123.00132-23.706h.01976zM144.7111 273.58024L227.921 129.48148l83.19012 144.09877h-166.4z"
297+
></path>
298+
<path
299+
fill="#108775"
300+
d="M396.04938 285.4321c-4.23344 7.33254-12.05656 11.85185-20.52345 11.85185H311.1111c13.0912 0 23.7037-10.6125 23.7037-23.7037h40.66173L260.09877 73.74815l-18.4889 32.02963-13.68888-23.7037L239.5753 61.8963c4.23416-7.33433 12.0596-11.85252 20.5284-11.85252 8.46879 0 16.29423 4.51819 20.52839 11.85252l115.41728 199.8321c4.23426 7.33395 4.23426 16.36975 0 23.7037z"
301+
></path>
302+
</g></svg
303+
><svg
304+
xmlns="http://www.w3.org/2000/svg"
305+
xmlns:xlink="http://www.w3.org/1999/xlink"
306+
aria-hidden="true"
307+
role="img"
308+
class="iconify iconify--nested"
309+
style="font-size: 32px"
310+
width="1em"
311+
height="1em"
312+
viewBox="0 0 512 512"
313+
>
314+
<g fill="none">
315+
<path
316+
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"
317+
fill="#00DC82"
318+
></path>
319+
</g></svg
320+
><svg
321+
xmlns="http://www.w3.org/2000/svg"
322+
xmlns:xlink="http://www.w3.org/1999/xlink"
323+
aria-hidden="true"
324+
role="img"
325+
class="iconify iconify--nested"
326+
style="font-size: 32px"
327+
width="1em"
328+
height="1em"
329+
viewBox="0 0 124 124"
330+
>
331+
<g fill="none">
332+
<path
333+
fill-rule="evenodd"
334+
clip-rule="evenodd"
335+
d="M55.75 27.155c-3.222-5.54-11.278-5.54-14.5 0L6.134 87.535C2.912 93.075 6.94 100 13.384 100h27.413c-2.753-2.407-3.773-6.57-1.69-10.142L65.704 44.27 55.75 27.155z"
336+
fill="#80EEC0"
337+
></path>
338+
<path
339+
d="M78 40.4c2.667-4.533 9.333-4.533 12 0L119.06 89.8c2.667 4.533-.666 10.199-5.999 10.199H54.938c-5.333 0-8.666-5.666-6-10.199L78 40.4z"
340+
fill="#00DC82"
341+
></path>
342+
</g></svg
343+
><svg
344+
xmlns="http://www.w3.org/2000/svg"
345+
xmlns:xlink="http://www.w3.org/1999/xlink"
346+
aria-hidden="true"
347+
role="img"
348+
class="iconify iconify--nested"
349+
style="font-size: 32px"
350+
width="1.36em"
351+
height="1em"
352+
viewBox="0 0 256 189"
353+
>
354+
<g>
355+
<polygon
356+
fill="#48B884"
357+
points="109.7766 0.0009 -0.0004 188.2259 219.5526 188.2259"
358+
></polygon>
359+
<polygon
360+
fill="#3F7F70"
361+
points="72.8361 188.226 255.9991 188.226 164.4181 31.198"
362+
></polygon>
363+
<polygon
364+
fill="#36495D"
365+
points="72.8361 188.226 219.5521 188.226 146.1941 62.444"
366+
></polygon>
367+
</g></svg
368+
><svg
369+
xmlns="http://www.w3.org/2000/svg"
370+
xmlns:xlink="http://www.w3.org/1999/xlink"
371+
aria-hidden="true"
372+
role="img"
373+
class="iconify iconify--nested"
374+
style="font-size: 32px"
375+
width="1.36em"
376+
height="1em"
377+
viewBox="0 0 256 189"
378+
>
379+
<g>
380+
<polygon
381+
fill="#48B884"
382+
points="109.7766 0.0009 -0.0004 188.2259 219.5526 188.2259"
383+
></polygon>
384+
<polygon
385+
fill="#3F7F70"
386+
points="72.8361 188.226 255.9991 188.226 164.4181 31.198"
387+
></polygon>
388+
<polygon
389+
fill="#36495D"
390+
points="72.8361 188.226 219.5521 188.226 146.1941 62.444"
391+
></polygon>
392+
</g>
393+
</svg>
394+
</p>
251395
<p>
252396
Custom icons with `prefix: ''` from local fs:
253397
<svg

0 commit comments

Comments
 (0)