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() {
|
||||
return (
|
||||
<Html lang='en'>
|
||||
<Body style={{ backgroundColor: '#61dafb' }}>
|
||||
<Section>
|
||||
<Column style={{ width: '50%' }}>First column</Column>
|
||||
<Column style={{ width: '50%' }}>Second column</Column>
|
||||
</Section>
|
||||
</Body>
|
||||
</Html>
|
||||
)
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
// 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