From f212b6c935444fd7f4dfd3d471701db49fdb6d7d Mon Sep 17 00:00:00 2001 From: gunshiz Date: Wed, 2 Sep 2026 17:43:03 +0700 Subject: [PATCH] fix(image-export) : render talent relation symbols --- .../[guideId]/artifacts/image/route.tsx | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/api/guides/[guideId]/artifacts/image/route.tsx b/app/api/guides/[guideId]/artifacts/image/route.tsx index 6fcd4b9..a63384f 100644 --- a/app/api/guides/[guideId]/artifacts/image/route.tsx +++ b/app/api/guides/[guideId]/artifacts/image/route.tsx @@ -1,4 +1,5 @@ /* eslint-disable @next/next/no-img-element */ +import { readFile } from "node:fs/promises"; import { join } from "node:path"; import { ImageResponse } from "next/og"; @@ -42,6 +43,10 @@ const anuphanFonts = Promise.all( }), ).catch(() => []); +const relationFont = readFile( + join(process.cwd(), "public", "Kanit-SemiBold.ttf"), +); + function metric(value: string): string { return `${Number(value).toLocaleString("en-US", { maximumFractionDigits: 2 })}%`; } @@ -110,9 +115,9 @@ export async function GET( if (!guide) return new Response("ไม่พบไกด์", { status: 404 }); const talents = normalizeTalentPriorities(guide.profile?.talents ?? []); - const [fonts, groupAssets, statIconAssets, talentAssets, targetStatAssets] = + const [fontAssets, groupAssets, statIconAssets, talentAssets, targetStatAssets] = await Promise.all([ - anuphanFonts, + Promise.all([anuphanFonts, relationFont]), Promise.all( guide.groups.map((group) => Promise.all( @@ -144,6 +149,7 @@ export async function GET( ), ), ]); + const [fonts, relationFontData] = fontAssets; const profile = guide.profile; const recommendedStatAsset = (value: string) => { @@ -707,7 +713,7 @@ export async function GET( {index < talents.length - 1 ? ( - + {talentRelationSymbol(talent.relationToNext)} ) : null} @@ -750,7 +756,15 @@ export async function GET( { width: 1200, height, - fonts: fonts.length ? fonts : undefined, + fonts: [ + ...fonts, + { + name: "Kanit", + data: relationFontData, + weight: 600, + style: "normal", + }, + ], headers: { "Cache-Control": "no-store", "Content-Disposition": imageContentDisposition(