Skip to content

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

Funksjon: simpleIcons()

simpleIcons(options?): PantokenPlugin

Beta

Opprett Simple Icons-pluginen.

Parametere

options?

SimpleIconsOptions = {}

SimpleIconsOptions. Send en registry for å unngå den forsinkede importen (f.eks. i bruk i token-stage, hvor hooks er synkrone).

Returnerer

PantokenPlugin

En PantokenPlugin med tokens- og rehype-hooks.

Eksempler

Generer merke-glyfer som <image>-tokens

ts
import { buildTokens } from "@pantoken/core/build";
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

Løs :brand:-koder ved rendering (rehype-laget)

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" }