Skip to content

pantoken / platforms/wordpress/src / toThemeJson

函数: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

实验性

将 IR 令牌列表转换为 WordPress theme.json

参数

tokens

只读 Token[]

IR(例如来自 @pantoken/tokens)。

options?

ToThemeJsonOptions = {}

ToThemeJsonOptions.

返回值

ThemeJson

一个 theme.json 文档。

示例

将 IR 转换为浅色模式的 theme.json

ts
import { toThemeJson } from "@pantoken/wordpress";
import { byTheme } from "@pantoken/tokens";

const doc = toThemeJson(byTheme("rebrand"));
doc.settings.color.palette; // [{ slug, name, color }, …]

深色模式

ts
import { toThemeJson } from "@pantoken/wordpress";
import { byTheme } from "@pantoken/tokens";

const doc = toThemeJson(byTheme("canvas"), { mode: "dark" });