Skip to content

pantoken / packages/plugin-kit/src / definePlugin

函式: definePlugin()

definePlugin(config): PantokenPlugin

Beta(測試)

從其 hooks 建立一個 pantoken 外掛。結果是一個普通的 PantokenPlugin,其品牌化標記包含從你提供的 hooks 推斷出的能力。

參數

config

PantokenPlugin

該外掛 name 以及任一 tokens/icons/css/rehype/native hooks。

回傳

PantokenPlugin

一個帶品牌標記的 PantokenPlugin

範例

一個統一的 tokens + css 外掛

ts
import { capabilitiesOf, definePlugin } from "@pantoken/plugin-kit";

const brand = definePlugin({
  name: "@acme/brand",
  tokens: (ctx) => [
    ...ctx.tokens,
    ctx.define({ name: "--instui-brand", value: "var(--instui-color-background-brand)" }),
  ],
  css: () => ({ append: ":root { color-scheme: light dark; }" }),
});

capabilitiesOf(brand); // → ["tokens", "css"]