rework to use new @besties/html2png
This commit is contained in:
parent
7d6cf5b09f
commit
cc40eb1fff
7 changed files with 97 additions and 172 deletions
|
@ -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}`)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue