@maizzle/framework
Version:
Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.
28 lines (27 loc) • 854 B
JavaScript
import { RenderContextKey } from "./renderContext.js";
import { inject } from "vue";
//#region src/composables/usePreheader.ts
const PREVIEW_LENGTH = 200;
/**
* Set the preheader text for the current email template.
*
* Injects a hidden `<div>` at the start of `<body>` with the preheader text
* followed by filler characters that prevent email clients from pulling
* in body content after the preheader.
*
* Usage in SFC <script setup>:
* ```ts
* usePreheader('Thanks for signing up!')
* usePreheader('Welcome!', { spaces: 50 })
* ```
*/
function usePreheader(text, options) {
const ctx = inject(RenderContextKey);
if (ctx) ctx.preheader = {
text,
fillerCount: options?.spaces !== void 0 ? Math.max(0, options.spaces) : Math.max(0, PREVIEW_LENGTH - text.length)
};
}
//#endregion
export { usePreheader };
//# sourceMappingURL=usePreheader.js.map