Skip to content

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

函数: simpleIcons()

simpleIcons(options?): PantokenPlugin

Beta

创建 Simple Icons 插件。

参数

options?

SimpleIconsOptions = {}

SimpleIconsOptions。传入一个 registry 以避免延迟导入(例如在 token-stage 使用中,钩子是同步的)。

返回值

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