From 4919f028c884a041da7ff098abb02389b4eac598 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Tue, 18 Apr 2023 03:02:17 +0800 Subject: ✨add envshare docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- envshare/pages/api/v1/og.tsx | 64 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 envshare/pages/api/v1/og.tsx (limited to 'envshare/pages/api/v1/og.tsx') diff --git a/envshare/pages/api/v1/og.tsx b/envshare/pages/api/v1/og.tsx new file mode 100644 index 0000000..dad6531 --- /dev/null +++ b/envshare/pages/api/v1/og.tsx @@ -0,0 +1,64 @@ +import { ImageResponse } from "@vercel/og"; +import { NextRequest } from "next/server"; + +export const config = { + runtime: "edge", +}; + +export default async function handler(req: NextRequest) { + try { + const { searchParams } = new URL(req.url); + // Redundant fallback alternate tagline + const title = searchParams.get("title") ?? "Share Environment Variables Securely"; + const subtitle = searchParams.get("subtitle") ?? "EnvShare"; + + const inter = await fetch(new URL("../../../public/fonts/Inter-SemiBold.ttf", import.meta.url)).then((res) => + res.arrayBuffer(), + ); + + // TODO: Fix tailwind classes on this route + return new ImageResponse( +
+ {/* backgroundImage: bg-gradient-to-tr from-zinc-900/50 to-zinc-700/30 */} +
+
+ {/* font-semibold bg-gradient-to-t bg-clip-text from-zinc-100/50 to-white whitespace-pre */} +

+ {title} +

+

{subtitle}

+
+
+
, + { + height: 630, + width: 1200, + emoji: "twemoji", + fonts: [ + { + name: "Inter", + data: inter, + style: "normal", + }, + ], + }, + ); + } catch (e) { + console.log(`${(e as Error).message}`); + return new Response("Failed to generate the image", { + status: 500, + }); + } +} -- cgit v1.2.3-70-g09d2