Skip to content

Commit

Permalink
feat: add dynamic og
Browse files Browse the repository at this point in the history
  • Loading branch information
fedeya committed Nov 9, 2024
1 parent 892b339 commit f397bd1
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/web-2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
Expand Down
Empty file added apps/web-2/public/.gitkeep
Empty file.
1 change: 0 additions & 1 deletion apps/web-2/public/file.svg

This file was deleted.

1 change: 0 additions & 1 deletion apps/web-2/public/globe.svg

This file was deleted.

1 change: 0 additions & 1 deletion apps/web-2/public/next.svg

This file was deleted.

Binary file removed apps/web-2/public/og-home.jpg
Binary file not shown.
1 change: 0 additions & 1 deletion apps/web-2/public/vercel.svg

This file was deleted.

1 change: 0 additions & 1 deletion apps/web-2/public/window.svg

This file was deleted.

8 changes: 8 additions & 0 deletions apps/web-2/src/app/about/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export const metadata: Metadata = {
alternates: {
canonical: 'https://fedeminaya.com/about',
},
openGraph: {
images: [
{
type: 'image/jpeg',
url: 'https://fedeminaya.com/og?page=About',
},
],
},
};

export default function About() {
Expand Down
Binary file removed apps/web-2/src/app/fonts/GeistMonoVF.woff
Binary file not shown.
Binary file removed apps/web-2/src/app/fonts/GeistVF.woff
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/web-2/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const metadata: Metadata = {
images: [
{
type: 'image/jpeg',
url: 'https://fedeminaya.com/og-home.jpg',
url: 'https://fedeminaya.com/og',
},
],
},
Expand Down
57 changes: 57 additions & 0 deletions apps/web-2/src/app/og/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { ImageResponse } from 'next/og';

export const runtime = 'edge';

export const GET = async (req: Request) => {
const url = new URL(req.url);

const page = url.searchParams.get('page');

const fontRegular = fetch(
new URL('../../assets/fonts/JetBrainsMono-Regular.ttf', import.meta.url)
).then((res) => res.arrayBuffer());

const fontBold = fetch(
new URL('../../assets/fonts/JetBrainsMono-Bold.ttf', import.meta.url)
).then((res) => res.arrayBuffer());

return new ImageResponse(
(
<div
style={{ width: '100%', height: '100%', display: 'flex' }}
tw="justify-center flex-col gap-10 bg-white items-center"
>
<h1 tw="text-7xl font-bold">Federico Minaya</h1>

<div
// style={{ borderWidth: 4, borderStyle: 'solid' }}
tw="flex flex-col"
>
<h2 tw="text-4xl mb-2 font-normal text-purple-800">
{page ?? 'Full Stack Developer'}
</h2>

<div tw="h-1 bg-purple-800"></div>
</div>
</div>
),
{
width: 1200,
fonts: [
{
name: 'JetBrains Mono',
data: await fontRegular,
style: 'normal',
weight: 400,
},
{
name: 'JetBrains Mono',
data: await fontBold,
style: 'normal',
weight: 700,
},
],
height: 630,
}
);
};
Binary file not shown.
Binary file not shown.

0 comments on commit f397bd1

Please sign in to comment.