20 lines
495 B
JavaScript
20 lines
495 B
JavaScript
import html2png, { renderHtml as htmlParser } from '@besties/html2png'
|
|
import fs from 'node:fs'
|
|
import { DMSans } from './fonts.js'
|
|
|
|
const css = fs.readFileSync('./assets/style.css', 'utf8')
|
|
|
|
const renderOptions = {
|
|
fonts: DMSans
|
|
}
|
|
|
|
export default async function (html, options = {}) {
|
|
return html2png(html, css, { ...renderOptions, ...options })
|
|
}
|
|
|
|
export async function renderHtml(html) {
|
|
return htmlParser(
|
|
html,
|
|
await fs.promises.readFile('./assets/style.css', 'utf8')
|
|
).outerHTML
|
|
}
|