og/lib/render.js

36 lines
730 B
JavaScript
Raw Normal View History

2023-08-02 18:37:47 -04:00
import html2png from '@besties/html2png'
import fs from 'node:fs'
const figtreeRegular = fs.readFileSync('./assets/Figtree-Regular.woff')
const figtreeMedium = fs.readFileSync('./assets/Figtree-Medium.woff')
const figtreeExtraBold = fs.readFileSync('./assets/Figtree-ExtraBold.woff')
const css = fs.readFileSync('./assets/style.css', 'utf8')
const renderOptions = {
fonts: [
{
name: 'Figtree',
data: figtreeRegular,
weight: 400,
style: 'normal'
},
{
name: 'Figtree',
data: figtreeMedium,
weight: 500,
style: 'normal'
},
{
name: 'Figtree',
data: figtreeExtraBold,
weight: 800,
style: 'normal'
}
]
}
export default function (html) {
return html2png(html, css, renderOptions)
}