/** * Small HTML helpers for Kit email bodies. These emit generic Liquid/HTML — * they do not encode a particular sender, list, or template. */ export function buildLiquidGreeting(options: { withName: string; withoutName: string }): string { return `

{% if subscriber.first_name != blank %}${options.withName}{% else %}${options.withoutName}{% endif %}

` } export function buildParagraph(html: string): string { return `

${html}

` } export function buildLinkedImage(options: { href: string; src: string; alt?: string }): string { const alt = options.alt ?? '' return `

${alt}

` } export function buildLinkedImageBlock(options: { href: string src: string alt?: string caption?: string }): string { const alt = options.alt ?? '' const figcaption = options.caption ? `
${options.caption}
` : '' return `
${alt}${figcaption}
` } export function buildUnorderedList(items: Array): string { const lis = items.map((item) => `
  • ${item}
  • `).join('\n') return `` } export function joinEmailBlocks(blocks: Array, options: { separator?: string } = {}): string { return blocks.filter(Boolean).join(options.separator ?? '\n\n') } /** * HTML builder catalog. * @example * import html from 'kody:@kody/kit/html' * const catalog = await html() */ export default async function htmlOverview() { return { builders: [ 'buildLiquidGreeting', 'buildParagraph', 'buildLinkedImage', 'buildLinkedImageBlock', 'buildUnorderedList', 'joinEmailBlocks', ], } }