UNPKG

@maizzle/framework

Version:

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

71 lines (70 loc) 2.44 kB
import { ChildNode } from "domhandler"; //#region src/transformers/base.d.ts /** * Options for the `base` transformer. */ interface BaseUrlOptions { /** Base URL to prepend to relative links. */ url?: string; /** * Tag/attribute scope for prepending. Omit to use the built-in defaults * (`a[href]`, `img[src]`, `link[href]`, etc.). * * - Array of tag names — restrict the built-in defaults to these tags. * - Object — explicit per-tag attribute map. Each attribute value is * `true` (use the base url) or a string (use that string as the url * for this attribute only). */ tags?: string[] | Record<string, Record<string, string | boolean>>; /** * Custom attributes to rewrite globally, regardless of tag. Each key * is the attribute name; the value is the URL to prepend. */ attributes?: Record<string, string>; /** * Rewrite `url()` references inside `<style>` tag contents. * * @default true */ styleTag?: boolean; /** * Rewrite `url()` references inside inline `style` attributes. * * @default true */ inlineCss?: boolean; } /** * Prepend a base URL to relative `src`/`href`/etc. references throughout * the document, including inside `<style>` blocks, inline `style` * attributes, MSO conditional comments, and VML tags. * * @param html HTML string to transform. * @param options Either a base URL string, or a {@link BaseUrlOptions} object * for finer control. * @returns The transformed HTML string. * * @example * import { base } from '@maizzle/framework' * * // Just a URL — applied with the built-in tag/attribute defaults. * const out = base('<img src="/a.png">', 'https://cdn.example.com/') * * // Restrict to specific tags, opt out of style rewriting: * const limited = base(html, { * url: 'https://cdn.example.com/', * tags: ['img'], * styleTag: false, * inlineCss: false, * }) */ declare function base(html: string, options: string | BaseUrlOptions): string; /** * DOM-form of {@link base} used by the internal transformer pipeline. * Takes a parsed DOM, returns a parsed DOM — avoids redundant * serialize/parse round-trips when chained with other transformers. */ declare function baseDom(dom: ChildNode[], options: string | BaseUrlOptions | undefined | null | false): ChildNode[]; //#endregion export { BaseUrlOptions, base, baseDom }; //# sourceMappingURL=base.d.ts.map