Skip to content

pantoken / platforms/wordpress/src / toThemeJson

تابع: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

تجربی

تبدیل فهرست توکن‌های IR به یک theme.json برای WordPress.

پارامترها

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