2023-12-09 00:02:30 +00:00
|
|
|
import type { RequestHandler } from '@sveltejs/kit';
|
|
|
|
|
import SocialImageCard from '$lib/components/socialImageCard.svelte';
|
2023-12-09 01:04:31 +00:00
|
|
|
import { componentToPng } from '$root/lib/renderImage';
|
2023-12-09 00:02:30 +00:00
|
|
|
|
|
|
|
|
const height = 630;
|
|
|
|
|
const width = 1200;
|
|
|
|
|
|
|
|
|
|
export const GET: RequestHandler = async ({ url }) => {
|
|
|
|
|
try {
|
|
|
|
|
const ogImage = `${new URL(url.origin).href}/b_shell_nut_favicon.png`;
|
|
|
|
|
const header = url.searchParams.get('header') ?? undefined;
|
|
|
|
|
const page = url.searchParams.get('page') ?? undefined;
|
|
|
|
|
const content = url.searchParams.get('content') ?? '';
|
2023-12-09 01:04:31 +00:00
|
|
|
|
|
|
|
|
return componentToPng(SocialImageCard, {
|
2023-12-09 00:02:30 +00:00
|
|
|
header,
|
|
|
|
|
page,
|
|
|
|
|
content,
|
|
|
|
|
image: ogImage,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
url: new URL(url.origin).href
|
2023-12-09 01:04:31 +00:00
|
|
|
}, height, width);
|
2023-12-09 00:02:30 +00:00
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e);
|
|
|
|
|
}
|
|
|
|
|
};
|