diff --git a/src/assets/NotoSansHans-Regular-2.ttf b/src/assets/NotoSansHans-Regular-2.ttf deleted file mode 100644 index 0c4e8e9..0000000 Binary files a/src/assets/NotoSansHans-Regular-2.ttf and /dev/null differ diff --git a/src/assets/ZCOOLKuaiLe-Regular.ttf b/src/assets/ZCOOLKuaiLe-Regular.ttf deleted file mode 100644 index d7157a3..0000000 Binary files a/src/assets/ZCOOLKuaiLe-Regular.ttf and /dev/null differ diff --git a/src/assets/roboto-mono-700.ttf b/src/assets/roboto-mono-700.ttf deleted file mode 100644 index 180a726..0000000 Binary files a/src/assets/roboto-mono-700.ttf and /dev/null differ diff --git a/src/assets/roboto-mono-regular.ttf b/src/assets/roboto-mono-regular.ttf deleted file mode 100644 index de0f485..0000000 Binary files a/src/assets/roboto-mono-regular.ttf and /dev/null differ diff --git a/src/pages/og-image/[...slug].png.ts b/src/pages/og-image/[...slug].png.ts deleted file mode 100644 index 427f9f3..0000000 --- a/src/pages/og-image/[...slug].png.ts +++ /dev/null @@ -1,90 +0,0 @@ -import RobotoMonoBold from "@/assets/roboto-mono-700.ttf"; -import RobotoMono from "@/assets/roboto-mono-regular.ttf"; -import Zcoolkuaile from "@/assets/ZCOOLKuaiLe-Regular.ttf"; -import { siteConfig } from "@/site-config"; - -import { Resvg } from "@resvg/resvg-js"; -import type { APIContext, InferGetStaticPropsType } from "astro"; -import satori, { type SatoriOptions } from "satori"; -import { html } from "satori-html"; -import { getSortedAllPostsAndDiaries } from "src/utils/post"; - -const ogOptions: SatoriOptions = { - // debug: true, - fonts: [ - { - data: Buffer.from(RobotoMono), - name: "Roboto Mono", - style: "normal", - weight: 400, - }, - { - data: Buffer.from(RobotoMonoBold), - name: "Roboto Mono", - style: "normal", - weight: 700, - }, - { - data: Buffer.from(Zcoolkuaile), - name: "ZCOOL KuaiLe", - style: "normal", - weight: 400, - }, - ], - height: 630, - width: 1200, -}; - -const markup = (title: string, pubDate: string) => - html`
-
-

${pubDate}

-

${title}

-
-
-
- avatar -

${siteConfig.title}

-
-

by ${siteConfig.author}

-
-
`; - -type Props = InferGetStaticPropsType; - -export async function GET(context: APIContext) { - const { pubDate, title } = context.props as Props; - console.log("context.props", context.props) - const postDate = pubDate instanceof Date - ? pubDate.toLocaleDateString('zh-CN', { - year: 'numeric', - month: 'long', - day: 'numeric' - }) - : pubDate; - - const htmlElement = markup(title, postDate); - const svg = await satori(htmlElement, ogOptions); - const png = new Resvg(svg).render().asPng(); - return new Response(png, { - headers: { - "Cache-Control": "public, max-age=31536000, immutable", - "Content-Type": "image/png", - }, - }); -} - -export async function getStaticPaths() { - const posts = await getSortedAllPostsAndDiaries(); - return posts - .filter(({ data }) => !data.ogImage) - .map((post) => ({ - params: { slug: post.id }, - props: { - pubDate: post.data?.date, - title: post.data.title, - }, - })); -} - -export const prerender = true; \ No newline at end of file