UNPKG

@maizzle/framework

Version:

Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.

32 lines (31 loc) 948 B
import { MaizzleConfigKey } from "./useConfig.js"; import { RenderContextKey } from "./renderContext.js"; import { createDefu } from "defu"; import { getCurrentInstance, inject, provide } from "vue"; //#region src/composables/defineConfig.ts const merge = createDefu((obj, key, value) => { if (Array.isArray(obj[key])) { obj[key] = value; return true; } }); /** * Define Maizzle config. * * In maizzle.config.ts: typed identity function, returns the config as-is * In Vue SFC `<script setup>`: merges with the global config and provides * the result to child components via `useConfig()` */ function defineConfig(data = {}) { if (getCurrentInstance()) { const merged = merge(data, inject(MaizzleConfigKey, {})); const ctx = inject(RenderContextKey); if (ctx) ctx.sfcConfig = merged; provide(MaizzleConfigKey, merged); return merged; } return data; } //#endregion export { defineConfig }; //# sourceMappingURL=defineConfig.js.map