2023-12-09 00:02:30 +00:00
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 ;
2024-01-24 19:26:31 +00:00
/** @type {import('./$types').RequestHandler} */
2023-12-12 00:26:10 +00:00
export async function GET ( { url } ) {
2023-12-09 00:02:30 +00:00
try {
2024-01-24 19:26:31 +00:00
const faviconImageName = 'b_shell_nut_favicon.png' ;
const image = ` ${ new URL ( url . origin ) . href } ${ faviconImageName } ` ;
2023-12-09 00:02:30 +00:00
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
2024-01-25 05:13:15 +00:00
// @ts-expect-error: Argument of type 'typeof SocialImageCard__SvelteComponent_' is not assignable to parameter of type 'SvelteComponent<any, any, any>'
2023-12-09 01:04:31 +00:00
return componentToPng ( SocialImageCard , {
2023-12-09 00:02:30 +00:00
header ,
page ,
content ,
2024-01-24 19:26:31 +00:00
image ,
2023-12-12 00:26:10 +00:00
width : ` ${ width } ` ,
height : ` ${ height } ` ,
2023-12-09 00:02:30 +00:00
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 ) ;
}
2023-12-12 00:26:10 +00:00
}