13 lines
454 B
JavaScript
13 lines
454 B
JavaScript
import html2png, { renderHtml as htmlParser } from '@besties/html2png'
|
|
import fs from 'node:fs'
|
|
|
|
const style = fs.readFileSync('./assets/style.css', 'utf8')
|
|
|
|
export default async function (html, options = {}) {
|
|
return html2png(`<style>${style}</style>${html}`, options)
|
|
}
|
|
|
|
export async function renderHtml(html) {
|
|
const styleNow = await fs.promises.readFile('./assets/style.css', 'utf8')
|
|
return await htmlParser(`<style>${styleNow}</style>${html}`)
|
|
}
|