From 18161a50e851e031c4b3c3aae747d9670ded31b4 Mon Sep 17 00:00:00 2001 From: Ryan Freeman Date: Thu, 10 Oct 2024 22:32:49 +0100 Subject: [PATCH] New post --- app/api/og-image/route.tsx | 6 +- app/services/page.tsx | 9 +- .../open-graph-meta-tags.png | Bin 0 -> 81965 bytes .../page.mdx | 145 ++++++++++++++++++ app/writing/page.tsx | 23 ++- lib/createSlug.ts | 4 +- 6 files changed, 176 insertions(+), 11 deletions(-) create mode 100644 app/writing/generating-dynamic-open-graph-images-with-nextjs/open-graph-meta-tags.png create mode 100644 app/writing/generating-dynamic-open-graph-images-with-nextjs/page.mdx diff --git a/app/api/og-image/route.tsx b/app/api/og-image/route.tsx index 1bd4cbe..4aa1d1d 100644 --- a/app/api/og-image/route.tsx +++ b/app/api/og-image/route.tsx @@ -17,7 +17,7 @@ const gradients = [ export async function GET(request: Request) { const fontData = await font const {searchParams} = new URL(request.url) - const title = searchParams.get('title') + const text = searchParams.get('text') return new ImageResponse( ( @@ -44,7 +44,7 @@ export async function GET(request: Request) { '-webkit-background-clip': 'text', color: 'transparent', }}> - {title} + {text} ), @@ -59,5 +59,5 @@ export async function GET(request: Request) { } ] } - ); + ) } \ No newline at end of file diff --git a/app/services/page.tsx b/app/services/page.tsx index 3edba97..4169524 100644 --- a/app/services/page.tsx +++ b/app/services/page.tsx @@ -24,13 +24,14 @@ export const metadata = { description: meta.description, images: [ { - url: `/api/og-image?title=${meta.heading}`, + url: `/api/og-image?text=${meta.heading}`, width: 1200, height: 600, alt: meta.heading, type: 'image/png' } - ] + ], + type: 'website' } } @@ -98,7 +99,7 @@ export default function Services() { return (