From 09063806e15dd5a8bb2c2d33a880805d42699244 Mon Sep 17 00:00:00 2001 From: arrow2nd <44780846+arrow2nd@users.noreply.github.com> Date: Thu, 23 Nov 2023 12:02:59 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20=E7=89=B9=E6=AE=8A=E6=96=87?= =?UTF-8?q?=E5=AD=97=E3=81=8CTofu=E3=81=AB=E3=81=AA=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/[id]/opengraph-image.tsx | 53 ++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/app/[id]/opengraph-image.tsx b/app/[id]/opengraph-image.tsx index a393c11..e24953f 100644 --- a/app/[id]/opengraph-image.tsx +++ b/app/[id]/opengraph-image.tsx @@ -4,6 +4,8 @@ import { getPoem, splitPoemText } from "libs/utils"; import { SiteInfo } from "data/site"; +import { Poem } from "types/poem"; + export const runtime = "edge"; export const alt = SiteInfo.description; @@ -22,17 +24,19 @@ export default async function Image({ params }: { params: { id: string } }) { }); } - const kiwiMaru = fetch( - new URL( - "https://fonts.bunny.net/kiwi-maru/files/kiwi-maru-japanese-400-normal.woff" - ) - ).then((res) => res.arrayBuffer()); + const kiwiMaru = await fetchFont(poem); + if (!kiwiMaru) { + return new Response("Failed to fetch font", { + status: 500 + }); + } const lines = splitPoemText(poem.text); return new ImageResponse( (