og/lib/render.js

16 lines
392 B
JavaScript
Raw Normal View History

2023-08-02 19:54:54 -04:00
import html2png, { renderHtml as htmlParser } from '@besties/html2png'
2023-08-02 18:37:47 -04:00
import fs from 'node:fs'
const css = fs.readFileSync('./assets/style.css', 'utf8')
2023-08-03 10:49:25 -04:00
export default async function (html, options = {}) {
2023-08-03 15:28:31 -04:00
return html2png(html, css, options)
2023-08-02 18:37:47 -04:00
}
2023-08-02 19:54:54 -04:00
export async function renderHtml(html) {
return htmlParser(
html,
await fs.promises.readFile('./assets/style.css', 'utf8')
).outerHTML
}