-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
16 changed files
with
82 additions
and
76 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
Binary file not shown.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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,51 @@ | ||
import { BASE_URL } from "@/lib/constants"; | ||
import { type BlogPageProps, getPost } from "@/lib/posts"; | ||
import { ImageResponse } from "next/og"; | ||
import type { NextRequest } from "next/server"; | ||
|
||
export const alt = "About Acme"; | ||
export const size = { | ||
width: 1200, | ||
height: 630, | ||
}; | ||
export const contentType = "image/png"; | ||
export const dynamic = "force-static"; | ||
|
||
export async function GET(_: NextRequest, params: BlogPageProps) { | ||
const post = getPost(params); | ||
if (!post) { | ||
return new Response("Not found", { status: 404 }); | ||
} | ||
|
||
// Font | ||
const interSemiBold = fetch( | ||
`${BASE_URL}/fonts/Inter-SemiBold.ttf`, | ||
).then((res) => res.arrayBuffer()) | ||
|
||
return new ImageResponse( | ||
<div | ||
style={{ | ||
fontSize: 48, | ||
background: "white", | ||
width: "100%", | ||
height: "100%", | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
}} | ||
> | ||
{post.title} | ||
</div>, | ||
{ | ||
...size, | ||
fonts: [ | ||
{ | ||
name: 'Inter', | ||
data: await interSemiBold, | ||
style: 'normal', | ||
weight: 400, | ||
}, | ||
] | ||
}, | ||
); | ||
} |
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
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
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
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
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,11 @@ | ||
import { allPosts } from "contentlayer/generated"; | ||
|
||
export interface BlogPageProps { | ||
params: { slug: string[] }; | ||
} | ||
|
||
export const getPost = ({ params }: BlogPageProps) => { | ||
if (!params.slug) return null; | ||
const slug = params.slug.join("/"); | ||
return allPosts.find((post) => post.slug === slug); | ||
}; |