feat: add new render template process
This commit is contained in:
parent
3095db5781
commit
4f2fdef363
|
@ -1,27 +1,21 @@
|
||||||
import { Body, Column, Html, render, Section } from 'jsx-email'
|
import React from 'preact/compat' //for jsx-email
|
||||||
|
import { render } from 'jsx-email'
|
||||||
|
// @deno-types="npm:turndown"
|
||||||
|
import Turndown from 'turndown'
|
||||||
|
import { JSX } from 'preact'
|
||||||
|
|
||||||
function Email() {
|
const htmlToMd = new Turndown({
|
||||||
return (
|
headingStyle: 'atx',
|
||||||
<Html lang='en'>
|
codeBlockStyle: 'fenced',
|
||||||
<Body style={{ backgroundColor: '#61dafb' }}>
|
})
|
||||||
<Section>
|
|
||||||
<Column style={{ width: '50%' }}>First column</Column>
|
export async function renderTemplate(
|
||||||
<Column style={{ width: '50%' }}>Second column</Column>
|
template: JSX.Element,
|
||||||
</Section>
|
): Promise<{ html: string; text: string }> {
|
||||||
</Body>
|
const html = await render(template)
|
||||||
</Html>
|
|
||||||
)
|
return {
|
||||||
|
html,
|
||||||
|
text: htmlToMd.turndown(html),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log(await render(Email))
|
|
||||||
// import { render } from 'npm:preact-render-to-string'
|
|
||||||
|
|
||||||
// function Email() {
|
|
||||||
// return (
|
|
||||||
// <html>
|
|
||||||
// <p>Test</p>
|
|
||||||
// </html>
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
|
|
||||||
console.log(await render(<Email />))
|
|
||||||
|
|
Loading…
Reference in a new issue