rework to use new @besties/html2png

This commit is contained in:
hazycora 2023-09-10 13:48:50 -05:00
parent 7d6cf5b09f
commit cc40eb1fff
No known key found for this signature in database
GPG key ID: 215AF1F81F86940E
7 changed files with 97 additions and 172 deletions

View file

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