2024-12-02 03:14:16 +00:00
import SocialImageCard from "$lib/components/socialImageCard.svelte" ;
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-12-02 03:14:16 +00:00
const faviconImageName = "b_shell_nut_favicon.png" ;
2024-01-24 19:26:31 +00:00
const image = ` ${ new URL ( url . origin ) . href } ${ faviconImageName } ` ;
2024-12-02 03:14:16 +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>'
2024-12-02 03:14:16 +00:00
return componentToPng (
SocialImageCard ,
{
header ,
page ,
content ,
image ,
width : ` ${ width } ` ,
height : ` ${ height } ` ,
url : new URL ( url . origin ) . href ,
} ,
height ,
width
) ;
2023-12-09 00:02:30 +00:00
} catch ( e ) {
console . error ( e ) ;
}
2023-12-12 00:26:10 +00:00
}