Skip to content

pantoken / plugins/pantoken/simple-icons/src / simpleIcons

Function: simpleIcons()

simpleIcons(options?): PantokenPlugin

Beta

Create the Simple Icons plugin.

Parameters

options?

SimpleIconsOptions = {}

SimpleIconsOptions. Pass a registry to avoid the lazy import (e.g. in token-stage use, where hooks are synchronous).

Returns

PantokenPlugin

A PantokenPlugin with tokens and rehype hooks.

Examples

Emit brand glyphs as <image> tokens

ts
import { buildTokens } from "@pantoken/core";
import { simpleIcons } from "@pantoken/plugin-simple-icons";
import * as registry from "simple-icons";

buildTokens({
  theme: "rebrand",
  plugins: [simpleIcons({ registry, slugs: ["github", "react"] })],
});
// adds --instui-icon-github, --instui-icon-react as <image> tokens

Resolve :brand: codes at render (rehype layer)

ts
import { simpleIcons } from "@pantoken/plugin-simple-icons";
import * as registry from "simple-icons";

const { resolve } = simpleIcons({ registry }).rehype!({ resolve: () => undefined });
resolve("github"); // { name, path, svg, viewBox, source: "simple-icons" }