Skip to content

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

Hàm: simpleIcons()

simpleIcons(options?): PantokenPlugin

Beta

Tạo plugin Simple Icons.

Tham số

options?

SimpleIconsOptions = {}

SimpleIconsOptions. Truyền một registry để tránh import lười (ví dụ trong token-stage, nơi các hooks là đồng bộ).

Trả về

PantokenPlugin

Một PantokenPlugin với các hook tokensrehype.

Các ví dụ

Xuất glyph thương hiệu dưới dạng token <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

Phân giải các mã :brand: khi render (lớp rehype)

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