mailer/src/template.tsx

22 lines
468 B
TypeScript

import React from 'preact/compat' //for jsx-email
import { render } from 'jsx-email'
// @deno-types="npm:turndown"
import Turndown from 'turndown'
import type { JSX } from 'preact'
const htmlToMd = new Turndown({
headingStyle: 'atx',
codeBlockStyle: 'fenced',
})
export async function renderTemplate(
template: JSX.Element,
): Promise<{ html: string; text: string }> {
const html = await render(template)
return {
html,
text: htmlToMd.turndown(html),
}
}