@@ -12,19 +12,6 @@ export const config = {
1212 unstable_allowDynamic : [ "/node_modules/.pnpm/**" ] ,
1313} ;
1414
15- const regularFont = fetch (
16- new URL ( "../../../social-card-font/GeneralSans-Regular.otf" , import . meta. url ) ,
17- ) . then ( ( res ) => res . arrayBuffer ( ) ) ;
18- const semiBoldFont = fetch (
19- new URL (
20- "../../../social-card-font/GeneralSans-Semibold.otf" ,
21- import . meta. url ,
22- ) ,
23- ) . then ( ( res ) => res . arrayBuffer ( ) ) ;
24- const mainIllustration = fetch (
25- new URL ( "../../../../public/images/main-illustration.png" , import . meta. url ) ,
26- ) . then ( ( res ) => res . arrayBuffer ( ) ) ;
27-
2815const getDays = ( { start, end } : { start : string ; end : string } ) => {
2916 // assuming the same month
3017 const startDate = new Date ( start ) ;
@@ -50,6 +37,25 @@ const getYear = ({ end }: { end: string }) => {
5037} ;
5138
5239const handler = async ( req : NextRequest ) => {
40+ const regularFont = fetch (
41+ new URL (
42+ "./social-card-font/GeneralSans-Regular.otf" ,
43+ req . url . substring ( 0 , req . url . lastIndexOf ( "/api" ) ) ,
44+ ) ,
45+ ) . then ( ( res ) => res . arrayBuffer ( ) ) ;
46+ const semiBoldFont = fetch (
47+ new URL (
48+ "./social-card-font/GeneralSans-Semibold.otf" ,
49+ req . url . substring ( 0 , req . url . lastIndexOf ( "/api" ) ) ,
50+ ) ,
51+ ) . then ( ( res ) => res . arrayBuffer ( ) ) ;
52+ const mainIllustration = fetch (
53+ new URL (
54+ "./images/main-illustration.png" ,
55+ req . url . substring ( 0 , req . url . lastIndexOf ( "/api" ) ) ,
56+ ) ,
57+ ) . then ( ( res ) => res . arrayBuffer ( ) ) ;
58+
5359 const [ regularFontData , semiBoldFontData , mainIllustrationData ] =
5460 await Promise . all ( [ regularFont , semiBoldFont , mainIllustration ] ) ;
5561 const client = createClient ( ) ;
@@ -70,9 +76,12 @@ const handler = async (req: NextRequest) => {
7076 fontFamily : '"GeneralSans"' ,
7177 } }
7278 >
73- { /* eslint-disable @typescript-eslint/ban-ts-comment */ }
74- { /* @ts -ignore */ }
75- < img width = { 600 } height = { "100%" } src = { mainIllustrationData } alt = "" />
79+ < img
80+ width = { 600 }
81+ height = { "100%" }
82+ src = { mainIllustrationData as unknown as string }
83+ alt = ""
84+ />
7685 < div
7786 style = { {
7887 display : "flex" ,
0 commit comments