From b7ebb668db94ce63fd29862152eac410be6bd098 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 19:47:58 +0900 Subject: [PATCH] =?UTF-8?q?og:image=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/post/og/[ogtitle].tsx | 129 -------------------------------- src/layouts/Layout.astro | 3 - 2 files changed, 132 deletions(-) delete mode 100644 functions/post/og/[ogtitle].tsx diff --git a/functions/post/og/[ogtitle].tsx b/functions/post/og/[ogtitle].tsx deleted file mode 100644 index ec7dd6f..0000000 --- a/functions/post/og/[ogtitle].tsx +++ /dev/null @@ -1,129 +0,0 @@ -import React from "react"; -import { ImageResponse } from "@cloudflare/pages-plugin-vercel-og/api"; - -interface OgImageProps { - ogTitle: string; -} - -const OgImage = ({ ogTitle }: OgImageProps): JSX.Element => { - return ( -
-
-

{ogTitle}

-
-

- - - - - - ゆっきー -

-

- ゆっきーの砂場 -

-
-
-
- ); -}; - -const getFontData = async (url: string): Promise => { - const css = await ( - await fetch(url, { - headers: { - "User-Agent": - "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1", - }, - }) - ).text(); - - const resource = css.match( - /src: url\((.+)\) format\('(opentype|truetype)'\)/ - ); - - if (resource === null) { - throw new Error("Font resource not found"); - } - - return await fetch(resource[1]).then(async (res) => await res.arrayBuffer()); -}; - -export const onRequest = async (context) => { - 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 new ImageResponse(, { - width: 800, - height: 400, - fonts: [ - { - name: "Noto Sans JP", - data: notoSansJpFontData, - style: "normal", - }, - { - name: "Reggae One", - data: reggeaeOneFontData, - style: "normal", - }, - ], - }); -}; diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 2e5628f..aac05f6 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -27,9 +27,6 @@ const canonicalURL = new URL(Astro.url.pathname, Astro.site); - - -