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

How to list all available custom icons #222

Open
Rednas83 opened this issue Jul 29, 2024 · 3 comments
Open

How to list all available custom icons #222

Rednas83 opened this issue Jul 29, 2024 · 3 comments

Comments

@Rednas83
Copy link

Usually I fetched the different icons with something like.

var icons = import.meta.glob(`.././assets/*.svg`, { as: "raw", eager: true })

for (const item in icons) {
  body.innerHTML = icons[item]
  let name = item.formatx(`../assets/$V.svg`)
  let color = body.querySelector("#color")?.getAttributeNS(null, "fill") || "black"
  let size = undefined // TODO

  result.push(await icon(`${name} c-${color}`, body.querySelector("svg") || undefined))
}

But this returns
image

Is there a better way?

@antfu
Copy link
Member

antfu commented Oct 28, 2024

We might need to add a DevTools tab for it. Or do you mean to get them from at the runtime?

@antfu
Copy link
Member

antfu commented Oct 28, 2024

@Rednas83
Copy link
Author

I meant to list the custom svg files from the customCollections

export default defineNuxtConfig({
  modules: [
    '@nuxt/icon'
  ],
  ssr: false,
  icon: {
    provider: 'server', // <-- this
    customCollections: [
      {
        prefix: 'my-icon',
        dir: './assets/my-icons'
      },
    ],
  },
})

Is there a convenient way to do that?

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

No branches or pull requests

2 participants