mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-21 12:53:56 +01:00
23 lines
598 B
TypeScript
23 lines
598 B
TypeScript
import { readFileSync } from 'fs';
|
|
import satori from 'satori';
|
|
import robotoBlack from './Roboto-Black.ttf';
|
|
import robotoBold from './Roboto-Bold.ttf';
|
|
import roboto from './Roboto.ttf';
|
|
|
|
const fonts = [
|
|
{ file: roboto, weight: 400 as const },
|
|
{ file: robotoBold, weight: 700 as const },
|
|
{ file: robotoBlack, weight: 900 as const },
|
|
];
|
|
|
|
export default async function jsxToSvg(jsx: JSX.Element) {
|
|
return await satori(jsx, {
|
|
width: 480,
|
|
fonts: fonts.map(({ file, weight }) => ({
|
|
weight,
|
|
name: 'Roboto',
|
|
data: readFileSync(`${__dirname}/${file}`),
|
|
})),
|
|
});
|
|
}
|