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