Iconify.Fetcher (Iconify v0.2.0)

Copy Markdown View Source

Fetches icon data from Iconify sources.

Sources

  • NPM - Fetches complete icon sets from @iconify-json/{prefix} packages
  • API - Fetches individual icons from api.iconify.design

Examples

# Fetch entire icon set
{:ok, set} = Iconify.Fetcher.fetch_set("heroicons")

# Fetch specific icons
{:ok, icons} = Iconify.Fetcher.fetch_icons("heroicons", ["user", "home"])

Summary

Functions

Fetches a single icon from the Iconify API.

Fetches specific icons from the Iconify API.

Fetches a complete icon set from NPM.

Returns the URL for an icon set's NPM package info.

Functions

fetch_icon(prefix, name)

@spec fetch_icon(String.t(), String.t()) :: {:ok, Iconify.Icon.t()} | {:error, term()}

Fetches a single icon from the Iconify API.

Examples

{:ok, icon} = Iconify.Fetcher.fetch_icon("heroicons", "user")

fetch_icons(prefix, names)

@spec fetch_icons(String.t(), [String.t()]) ::
  {:ok, %{required(String.t()) => Iconify.Icon.t()}} | {:error, term()}

Fetches specific icons from the Iconify API.

Returns a map of icon name to Icon struct.

Examples

{:ok, icons} = Iconify.Fetcher.fetch_icons("heroicons", ["user", "home"])
# => %{"user" => %Icon{}, "home" => %Icon{}}

fetch_set(prefix)

@spec fetch_set(String.t()) :: {:ok, Iconify.Set.t()} | {:error, term()}

Fetches a complete icon set from NPM.

Downloads the @iconify-json/{prefix} package and parses its icons.json.

Examples

{:ok, set} = Iconify.Fetcher.fetch_set("heroicons")
{:ok, set} = Iconify.Fetcher.fetch_set("mdi")

npm_package_url(prefix)

@spec npm_package_url(String.t()) :: String.t()

Returns the URL for an icon set's NPM package info.