Skip to content

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

函式: simpleIcons()

simpleIcons(options?): PantokenPlugin

Beta(測試)

建立 Simple Icons 外掛。

參數

options?

SimpleIconsOptions = {}

SimpleIconsOptions。傳入 registry 以避免延遲匯入(例如在 token-stage 使用,hooks 為同步)。

回傳

PantokenPlugin

具有 tokensrehype 鉤子的 PantokenPlugin

範例

將品牌字形以 <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" }