Files
sveltekit-og/src/routes/component-og/+server.ts
2023-06-10 19:23:58 +05:30

27 lines
641 B
TypeScript

import OG from './OG.svelte';
import { componentToImageResponse } from '$lib';
import type { RequestHandler } from '@sveltejs/kit';
const fontFile = await fetch(
'https://raw.githubusercontent.com/etherCorps/sveltekit-og/main/static/inter-latin-ext-700-normal.woff'
);
const fontData: ArrayBuffer = await fontFile.arrayBuffer();
export const GET: RequestHandler = async () => {
return await componentToImageResponse(
OG,
{ text: 'Ready to dive in?', spanText: 'Start your free trial today.' },
{
height: 250,
width: 500,
fonts: [
{
name: 'Inter Latin',
data: fontData,
weight: 700
}
]
}
);
};