-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71106d6
commit 0705f90
Showing
4 changed files
with
93 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ImageResponse } from "next/og"; | ||
import { RenderIMGEl } from "~/components/OGImgEl"; | ||
import Logo from "../../../../public/chad-next.png"; | ||
|
||
export const runtime = "edge"; | ||
|
||
export async function GET(request: Request) { | ||
const { searchParams } = new URL(request.url); | ||
const hasTitle = searchParams.has("title"); | ||
const title = hasTitle | ||
? searchParams.get("title") | ||
: "Quick Starter Template for your Next project"; | ||
|
||
try { | ||
return new ImageResponse( | ||
RenderIMGEl({ | ||
logo: process.env.NEXT_PUBLIC_APP_URL + Logo.src, | ||
title: title as string, | ||
}), | ||
{ | ||
width: 1200, | ||
height: 630, | ||
} | ||
); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} catch (e: any) { | ||
console.log(`${e.message}`); | ||
return new Response(`Failed to generate the image`, { | ||
status: 500, | ||
}); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/app/[locale]/opengraph-image.tsx → src/app/opengraph-image.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* eslint-disable @next/next/no-img-element */ | ||
export const RenderIMGEl = ({ | ||
logo, | ||
title, | ||
}: { | ||
logo: string; | ||
title: string; | ||
}) => { | ||
return ( | ||
<div | ||
style={{ | ||
backgroundImage: | ||
"linear-gradient(to bottom right, #E0E7FF 25%, #ffffff 50%, #CFFAFE 75%)", | ||
}} | ||
tw="h-full w-full flex flex-col items-center justify-center bg-white" | ||
> | ||
<img | ||
src={logo} | ||
alt="ChadNext Logo" | ||
tw="w-20 h-20 mb-4 opacity-95" | ||
width={80} | ||
height={80} | ||
/> | ||
<h1 | ||
style={{ | ||
fontSize: "80px", | ||
fontWeight: 900, | ||
background: | ||
"linear-gradient(to bottom right, #000000 21.66%, #78716c 86.47%)", | ||
backgroundClip: "text", | ||
color: "transparent", | ||
lineHeight: "5rem", | ||
letterSpacing: "-0.02em", | ||
}} | ||
> | ||
ChadNext | ||
</h1> | ||
<h2 | ||
style={{ | ||
fontSize: "40px", | ||
fontWeight: 700, | ||
lineHeight: "5rem", | ||
letterSpacing: "-0.02em", | ||
}} | ||
> | ||
{title} | ||
</h2> | ||
</div> | ||
); | ||
}; |
0705f90
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
chadnext – ./
chadnext-moinulmoin.vercel.app
chadnext-git-main-moinulmoin.vercel.app
chadnext.vercel.app
chadnext.moinulmoin.com