Skip to content

Commit

Permalink
chore: update og image
Browse files Browse the repository at this point in the history
  • Loading branch information
mxkaske committed Dec 27, 2024
1 parent 0e18c38 commit 701238d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
8 changes: 6 additions & 2 deletions apps/web/src/app/(content)/blog/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export async function generateMetadata(props: {
}
const { title, publishedAt, description, slug, image } = post;

const encodedTitle = encodeURIComponent(title);
const encodedDescription = encodeURIComponent(description);
const encodedImage = encodeURIComponent(image);

return {
...defaultMetadata,
title,
Expand All @@ -42,7 +46,7 @@ export async function generateMetadata(props: {
url: `https://www.openstatus.dev/blog/${slug}`,
images: [
{
url: `https://openstatus.dev/api/og/post?title=${title}&image=${image}`,
url: `https://openstatus.dev/api/og/post?title=${encodedTitle}&image=${encodedImage}&description=${encodedDescription}`,
},
],
},
Expand All @@ -51,7 +55,7 @@ export async function generateMetadata(props: {
title,
description,
images: [
`https://openstatus.dev/api/og/post?title=${title}&image=${image}`,
`https://openstatus.dev/api/og/post?title=${encodedTitle}&image=${encodedImage}&description=${encodedDescription}`,
],
},
};
Expand Down
8 changes: 6 additions & 2 deletions apps/web/src/app/(content)/changelog/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export async function generateMetadata(props: {

const { title, publishedAt, description, slug, image } = post;

const encodedTitle = encodeURIComponent(title);
const encodedDescription = encodeURIComponent(description);
const encodedImage = encodeURIComponent(image);

return {
...defaultMetadata,
title,
Expand All @@ -46,7 +50,7 @@ export async function generateMetadata(props: {
url: `https://www.openstatus.dev/changelog/${slug}`,
images: [
{
url: `https://openstatus.dev/api/og/post?title=${title}&description=${description}&image=${image}`,
url: `https://openstatus.dev/api/og/post?title=${encodedTitle}&description=${encodedDescription}&image=${encodedImage}`,
},
],
},
Expand All @@ -55,7 +59,7 @@ export async function generateMetadata(props: {
title,
description,
images: [
`https://openstatus.dev/api/og/post?title=${title}&description=${description}&image=${image}`,
`https://openstatus.dev/api/og/post?title=${encodedTitle}&description=${encodedDescription}&image=${encodedImage}`,
],
},
};
Expand Down
11 changes: 8 additions & 3 deletions apps/web/src/app/api/og/_components/basic-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ export function BasicLayout({
<div tw="flex flex-col h-full w-full px-24">
<div tw="flex flex-col flex-1 justify-end">
<div tw="flex flex-col px-12">
<h1 style={{ fontFamily: "Cal" }} tw="text-6xl">
<h3 style={{ fontFamily: "Cal" }} tw="text-5xl">
{title}
</h1>
</h3>
{description ? (
<p tw="text-slate-600 text-3xl">{description}</p>
<p
tw="text-slate-600 text-3xl"
style={{ lineClamp: 2, display: "block" }}
>
{description}
</p>
) : null}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/api/og/post/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function GET(req: Request) {
{image ? (
<img
alt=""
style={{ objectFit: "cover", height: 350 }} // h-80 = 320px
style={{ objectFit: "cover", height: 330 }} // h-80 = 320px
tw="flex w-full"
src={new URL(image, DEFAULT_URL).toString()}
/>
Expand Down

0 comments on commit 701238d

Please sign in to comment.