mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-30 02:36:30 +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 { ImageResponse } from "next/og";
|
||||||
import type { NextRequest } from "next/server";
|
import type { NextRequest } from "next/server";
|
||||||
|
|
||||||
export const config = {
|
export const runtime = "edge";
|
||||||
runtime: "edge",
|
|
||||||
};
|
|
||||||
|
|
||||||
const regularFont = fetch(
|
const regularFont = fetch(
|
||||||
new URL("/public/static/fonts/inter-regular.ttf", import.meta.url),
|
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),
|
new URL("/public/static/fonts/inter-bold.ttf", import.meta.url),
|
||||||
).then((res) => res.arrayBuffer());
|
).then((res) => res.arrayBuffer());
|
||||||
|
|
||||||
export default async function handler(req: NextRequest) {
|
export async function GET(req: NextRequest) {
|
||||||
const [regularFontData, boldFontData] = await Promise.all([
|
const [regularFontData, boldFontData] = await Promise.all([
|
||||||
regularFont,
|
regularFont,
|
||||||
boldFont,
|
boldFont,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const { searchParams } = req.nextUrl;
|
const { searchParams } = new URL(req.url);
|
||||||
const title = searchParams.get("title");
|
const title = searchParams.get("title");
|
||||||
const excerpt = searchParams.get("excerpt");
|
const excerpt = searchParams.get("excerpt");
|
||||||
|
|
|
@ -8,9 +8,7 @@ const schema = z.object({
|
||||||
author: z.string().min(1),
|
author: z.string().min(1),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const config = {
|
export const runtime = "edge";
|
||||||
runtime: "edge",
|
|
||||||
};
|
|
||||||
|
|
||||||
const regularFont = fetch(
|
const regularFont = fetch(
|
||||||
new URL("/public/static/fonts/inter-regular.ttf", import.meta.url),
|
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),
|
new URL("/public/static/fonts/inter-bold.ttf", import.meta.url),
|
||||||
).then((res) => res.arrayBuffer());
|
).then((res) => res.arrayBuffer());
|
||||||
|
|
||||||
export default async function handler(req: NextRequest) {
|
export async function GET(req: NextRequest) {
|
||||||
const [regularFontData, boldFontData] = await Promise.all([
|
const [regularFontData, boldFontData] = await Promise.all([
|
||||||
regularFont,
|
regularFont,
|
||||||
boldFont,
|
boldFont,
|
||||||
]);
|
]);
|
||||||
const { searchParams } = req.nextUrl;
|
|
||||||
|
const { searchParams } = new URL(req.url);
|
||||||
|
|
||||||
const { title, author } = schema.parse({
|
const { title, author } = schema.parse({
|
||||||
title: searchParams.get("title"),
|
title: searchParams.get("title"),
|
Loading…
Add table
Reference in a new issue