From d96f8b0350a5ed9c0d0169ce1cd9282a25b611e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=89=E9=87=8E=E6=95=AC=E5=A4=AA=E9=83=8E?= Date: Mon, 16 Sep 2024 20:29:20 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20middleware=E3=82=92=E6=9B=B8=E3=81=8D?= =?UTF-8?q?=E7=9B=B4=E3=81=97=E3=81=A6=E3=81=BF=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/post/_middleware.tsx | 52 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/functions/post/_middleware.tsx b/functions/post/_middleware.tsx index c4d5be9..f8ec733 100644 --- a/functions/post/_middleware.tsx +++ b/functions/post/_middleware.tsx @@ -101,27 +101,27 @@ const getFontData = async (url: string): Promise => { return await fetch(resource[1]).then(async (res) => await res.arrayBuffer()); }; -export const onRequest = async () => { - const notoSansJpUrl = `https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@600`; - const reggeaeOneUlr = - "https://fonts.googleapis.com/css2?family=Reggae+One&display=swap&text=ゆっきーの砂場"; - const notoSansJpFontData = await getFontData(notoSansJpUrl); - const reggeaeOneFontData = await getFontData(reggeaeOneUlr); - return vercelOGPagesPlugin({ - imagePathSuffix: "/og-image.png", - component: ({ ogTitle }) => { - return ; - }, - extractors: { - on: { - 'meta[property="og:title"]': (props) => ({ - element(element) { - props.ogTitle = element.getAttribute("content"); - }, - }), - }, +export const onRequest = vercelOGPagesPlugin({ + imagePathSuffix: "/og-image.png", + component: ({ ogTitle }) => { + return ; + }, + extractors: { + on: { + 'meta[property="og:title"]': (props) => ({ + element(element) { + props.ogTitle = element.getAttribute("content"); + }, + }), }, - options: { + }, + options: async () => { + const notoSansJpUrl = `https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@600`; + const reggeaeOneUlr = + "https://fonts.googleapis.com/css2?family=Reggae+One&display=swap&text=ゆっきーの砂場"; + const notoSansJpFontData = await getFontData(notoSansJpUrl); + const reggeaeOneFontData = await getFontData(reggeaeOneUlr); + return { width: 800, height: 400, fonts: [ @@ -136,9 +136,9 @@ export const onRequest = async () => { style: "normal", }, ], - }, - autoInject: { - openGraph: true, - }, - }); -}; + }; + }, + autoInject: { + openGraph: true, + }, +});