mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-29 18:26:34 +02:00
♻️ Migrate og image api routes to app dir (#1586)
This commit is contained in:
parent
aebea5a41c
commit
83e3d85c97
2 changed files with 7 additions and 10 deletions
|
@ -2,9 +2,7 @@
|
|||
import { ImageResponse } from "next/og";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
export const config = {
|
||||
runtime: "edge",
|
||||
};
|
||||
export const runtime = "edge";
|
||||
|
||||
const regularFont = fetch(
|
||||
new URL("/public/static/fonts/inter-regular.ttf", import.meta.url),
|
||||
|
@ -14,13 +12,13 @@ const boldFont = fetch(
|
|||
new URL("/public/static/fonts/inter-bold.ttf", import.meta.url),
|
||||
).then((res) => res.arrayBuffer());
|
||||
|
||||
export default async function handler(req: NextRequest) {
|
||||
export async function GET(req: NextRequest) {
|
||||
const [regularFontData, boldFontData] = await Promise.all([
|
||||
regularFont,
|
||||
boldFont,
|
||||
]);
|
||||
|
||||
const { searchParams } = req.nextUrl;
|
||||
const { searchParams } = new URL(req.url);
|
||||
const title = searchParams.get("title");
|
||||
const excerpt = searchParams.get("excerpt");
|
||||
|
|
@ -8,9 +8,7 @@ const schema = z.object({
|
|||
author: z.string().min(1),
|
||||
});
|
||||
|
||||
export const config = {
|
||||
runtime: "edge",
|
||||
};
|
||||
export const runtime = "edge";
|
||||
|
||||
const regularFont = fetch(
|
||||
new URL("/public/static/fonts/inter-regular.ttf", import.meta.url),
|
||||
|
@ -20,12 +18,13 @@ const boldFont = fetch(
|
|||
new URL("/public/static/fonts/inter-bold.ttf", import.meta.url),
|
||||
).then((res) => res.arrayBuffer());
|
||||
|
||||
export default async function handler(req: NextRequest) {
|
||||
export async function GET(req: NextRequest) {
|
||||
const [regularFontData, boldFontData] = await Promise.all([
|
||||
regularFont,
|
||||
boldFont,
|
||||
]);
|
||||
const { searchParams } = req.nextUrl;
|
||||
|
||||
const { searchParams } = new URL(req.url);
|
||||
|
||||
const { title, author } = schema.parse({
|
||||
title: searchParams.get("title"),
|
Loading…
Add table
Reference in a new issue