nuxt / icon

The <Icon> component, supporting Iconify, Emojis and custom components.
https://stackblitz.com/edit/nuxt-icon-playground?file=app.vue
MIT License
864 stars 37 forks source link

iconifyApiOptions custom API not working #153

Closed leosin closed 1 month ago

leosin commented 2 months ago

I didn't quite understand that iconifyApiOptions in the document is only used to provide CDN for the default official api, or it can provide its own icon.

For example: First, I made sure that my custom API was written according to the official version and can be accessed normally.

https://localhost:3000/fal.json?icons=house

However, when I set the options below, it didn't work. Only when publicApiFallback:false is set will it work properly.

iconifyApiOptions: {
   url: 'http://localhost:3000',
   publicApiFallback: true,
},

// not working


Finally, when I was writing this question, I took a look at the nuxt-icon source code and found this snippet.

  if (appConfig.nuxtIcon?.iconifyApiOptions?.publicApiFallback) {
     addAPIProvider('custom', {
       resources: [appConfig.nuxtIcon?.iconifyApiOptions.url],
       index: 0
     })
     return
   }

// it works fine

Atinux commented 2 months ago

Could you please now check with the new version? https://github.com/nuxt-modules/icon/releases/tag/v1.0.0-beta.1

leosin commented 2 months ago

Thank you very much for the prompt update, now it works.

But there will be a warn

WARN [Icon] Collection myicon is not found locally
We suggest to install it via npm i -D @iconify-json/myicon to provide the best end-user experience.

In other words, do I still need to make a local package? I am not very sure.

antfu commented 1 month ago

Ah, that's a good point. We could probably disable the warning when a custom end point is provided.