Skip to content

pantoken / platforms/wordpress/src / toThemeJson

Fungsi: toThemeJson()

toThemeJson(tokens, options?): ThemeJson

Eksperimental

Mengonversi daftar token IR menjadi theme.json WordPress.

Parameter

tokens

hanya-baca Token[]

IR (mis. dari @pantoken/tokens).

options?

ToThemeJsonOptions = {}

ToThemeJsonOptions.

Mengembalikan

ThemeJson

Sebuah dokumen theme.json.

Contoh

Mengonversi IR menjadi theme.json untuk mode terang

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

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

Mode gelap

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

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