Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for @iconify/json icon sets in customCollections #87

Closed
jceb opened this issue Oct 8, 2021 · 1 comment · Fixed by #127
Closed

Add support for @iconify/json icon sets in customCollections #87

jceb opened this issue Oct 8, 2021 · 1 comment · Fixed by #127

Comments

@jceb
Copy link
Contributor

jceb commented Oct 8, 2021

As mentioned here, @iconfiy/json style icon sets are currently not supported by the customCollections attribute of unplugin-icons. Support for this feature would be very helpful to integrate commercial icons like Font Awesome Pro.

As an alternative to supporting json style icon sets a the loader function could be extended to apply the fill="currentColor" attribute and other useful defaults (see @iconify/utils/lib/customisations) to SVG files. This way commercial icons like Font Awesome Pro could be loaded directly.

Personally, I lean towards the alternative because it removes the JSON build step that's required for the first approach. Having said that, I'm not familiar with the implications of not going with the JSON approach.

@antfu
Copy link
Member

antfu commented Oct 8, 2021

I am not sure if what ./json/fab.json in your code snippet really is. But if it's compatible with Iconify's json data, I think we could export the icon resolver and maybe add an IconifyLoader to be reused for custom sources.

Meanwhile, I see your use FileSystemLoader in your first approach, #12 (comment), if that's preferable, we could have a custom transform function to FileSystemLoader as mentioned in #52.

So the usage could be like

"fap-brands": FileSystemIconLoader(
  "PATH_TO/node_modules/@fortawesome/fontawesome-pro/svgs/brands",
  svg => svg.replace(/^<svg /, '<svg fill="currentColor" ')
),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants