Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

fix: update how OG image routes

Dillion Verma3fc9a77b3c87
diff --git a/app/(marketing)/[...slug]/page.tsx b/app/(marketing)/[...slug]/page.tsx
index 7254c0f7..9537e18b 100644
--- a/app/(marketing)/[...slug]/page.tsx
+++ b/app/(marketing)/[...slug]/page.tsx
@@ -38,7 +38,7 @@ export async function generateMetadata({
const url = env.NEXT_PUBLIC_APP_URL;
- const ogUrl = new URL(`${url}/api/og`);
+ const ogUrl = new URL(`${url}/og`);
ogUrl.searchParams.set("heading", page.title);
ogUrl.searchParams.set("type", siteConfig.name);
ogUrl.searchParams.set("mode", "light");
diff --git a/app/(marketing)/showcase/[...slug]/page.tsx b/app/(marketing)/showcase/[...slug]/page.tsx
index 946deb53..0cecc6d6 100644
--- a/app/(marketing)/showcase/[...slug]/page.tsx
+++ b/app/(marketing)/showcase/[...slug]/page.tsx
@@ -35,7 +35,7 @@ export async function generateMetadata({
const url = env.NEXT_PUBLIC_APP_URL;
- const ogUrl = new URL(`${url}/api/og`);
+ const ogUrl = new URL(`${url}/og`);
ogUrl.searchParams.set("heading", page.title);
ogUrl.searchParams.set("type", siteConfig.name);
ogUrl.searchParams.set("mode", "light");
diff --git a/app/layout.tsx b/app/layout.tsx
index a086d219..2fc35884 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -16,7 +16,7 @@ export const metadata: Metadata = constructMetadata({
title: "Magic UI",
description:
"Beautiful UI components and templates to make your landing page look stunning.",
- image: absoluteUrl("/api/og"),
+ image: absoluteUrl("/og"),
});
export const viewport: Viewport = {
diff --git a/app/api/og/route.tsx b/app/og/route.tsx
similarity index 93%
rename from app/api/og/route.tsx
rename to app/og/route.tsx
index 3bd7adea..6880cc98 100644
--- a/app/api/og/route.tsx
+++ b/app/og/route.tsx
@@ -5,19 +5,19 @@ import { capitalize } from "@/lib/utils";
export const runtime = "edge";
const inter600 = fetch(
- new URL(`../../../assets/fonts/Inter-SemiBold.ttf`, import.meta.url),
+ new URL(`../../assets/fonts/Inter-SemiBold.ttf`, import.meta.url),
).then((res) => res.arrayBuffer());
const inter700 = fetch(
- new URL(`../../../assets/fonts/Inter-Bold.ttf`, import.meta.url),
+ new URL(`../../assets/fonts/Inter-Bold.ttf`, import.meta.url),
).then((res) => res.arrayBuffer());
const image = fetch(
- new URL("../../../assets/images/og-bg-2.jpg", import.meta.url),
+ new URL("../../assets/images/og-bg-2.jpg", import.meta.url),
).then((res) => res.arrayBuffer());
-const logo = fetch(new URL("../../../app/icon.png", import.meta.url)).then(
- (res) => res.arrayBuffer(),
+const logo = fetch(new URL("../../app/icon.png", import.meta.url)).then((res) =>
+ res.arrayBuffer(),
);
export async function GET(req: Request) {
diff --git a/config/site.ts b/config/site.ts
index 592359c3..7546d005 100644
--- a/config/site.ts
+++ b/config/site.ts
@@ -1,7 +1,7 @@
export const siteConfig = {
name: "Magic UI",
url: "https://magicui.design",
- ogImage: "https://magicui.design/api/og",
+ ogImage: "https://magicui.design/og",
description:
"Beautifully designed landing page components built with React & Tailwind CSS.",
links: {
diff --git a/contentlayer.config.ts b/contentlayer.config.ts
index b5b9e841..b56e13a7 100644
--- a/contentlayer.config.ts
+++ b/contentlayer.config.ts
@@ -22,7 +22,7 @@ const computedFields = {
image: {
type: "string",
resolve: (post: any) =>
- `${process.env.NEXT_PUBLIC_APP_URL}/api/og?title=${encodeURI(post.title)}`,
+ `${process.env.NEXT_PUBLIC_APP_URL}/og?title=${encodeURI(post.title)}`,
},
slug: {
type: "string",
diff --git a/lib/utils.ts b/lib/utils.ts
index 42905d4a..5a3a6ca1 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -57,7 +57,7 @@ export function absoluteUrl(path: string) {
export function constructMetadata({
title = "Magic UI - Modern React + Tailwind CSS components & Templates",
description = "Magic UI is a curated collection of the best landing page components built using React + Tailwind CSS + Framer Motion",
- image = absoluteUrl("/api/og"),
+ image = absoluteUrl("/og"),
...props
}: {
title?: string;