Skip to content

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

関数: simpleIcons()

simpleIcons(options?): PantokenPlugin

ベータ

Simple Icons プラグインを作成します。

パラメーター

options?

SimpleIconsOptions = {}

SimpleIconsOptions。遅延インポートを回避するには registry を渡してください(例:フックが同期的に動作する token-stage での使用)。

戻り値

PantokenPlugin

PantokenPlugin で、tokensrehype フックを持ちます。

ブランドのグリフを <image> トークンとして出力する

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

レンダリング時(rehype レイヤー)に :brand: コードを解決する

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