natemoo-re / astro-icon

Inline and sprite-based SVGs in Astro made easy!
https://astroicon.dev
Other
1.11k stars 62 forks source link

Cannot mark an icon as optional and allow it to silently be omitted #244

Open dhruvkb opened 3 weeks ago

dhruvkb commented 3 weeks ago

What version of astro-icon are you using?

1.1.1

Astro Info

Astro                    v4.16.2
Node                     v20.16.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/tailwind
                         @astrojs/mdx
                         watchPlugins
                         astro-icon

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I want to mark an icon as optional, i.e. the component should not raise an error if the icon does not exist in the iconDir directory. Currently if such an icon is referenced, the error takes over the whole page:

image

What's the expected result?

The component should log the error but not take down the entire site like it does currently.

Link to Minimal Reproducible Example

N/A

stramel commented 3 weeks ago

What's the use-case of an optional icon?

dhruvkb commented 3 weeks ago

I have icon names coming from an API where I want to supply some icons but let other icons be silently hidden.