From ecc120b3d293f92e77e8cddc2a6c09fca0bb449f Mon Sep 17 00:00:00 2001 From: Martin Eckardt Date: Thu, 25 Jul 2024 10:22:36 +0200 Subject: [PATCH 1/2] replace local course directory with gloabl --- app/api/og/[course]/route.tsx | 126 ++++++++++++++-------------------- content/courses.tsx | 2 +- 2 files changed, 53 insertions(+), 75 deletions(-) diff --git a/app/api/og/[course]/route.tsx b/app/api/og/[course]/route.tsx index 3031b9d8..eea5350c 100644 --- a/app/api/og/[course]/route.tsx +++ b/app/api/og/[course]/route.tsx @@ -1,30 +1,8 @@ /* eslint-disable react/no-unknown-property -- Tailwind CSS `tw` property */ import { ImageResponse } from 'next/og'; import type { NextRequest } from 'next/server'; +import COURSES, { Course } from '@/content/courses'; -interface Course { - param: string; - name: string; -} - -const courses: Course[] = [ - { - param: 'avalanche-fundamentals', - name: 'Avalanche Fundamentals', - }, - { - param: 'multi-chain-architecture', - name: 'Multi-Chain Architecture', - }, - { - param: 'teleporter', - name: 'Teleporter', - }, - { - param: 'customizing-evm', - name: 'Customizing EVM', - }, -]; export const runtime = 'edge'; @@ -44,7 +22,7 @@ export async function GET( OG({ title: title ?? 'Avalanche Academy', description: description ?? 'The Learning Platform for Avalanche Ecosystem', - course: courses.find((course) => course.param === params.course) ?? courses[0], + course: COURSES.official.find((course) => course.slug === params.course) ?? COURSES.official[0], }), { width: 767, @@ -59,62 +37,62 @@ function OG({ description, course, }: { - course: Course; title: string; description: string; + course: Course; }): React.ReactElement { return ( -
-
- - - Academy / {course.name} - -
-
- {title} - {description} -
-
-
+
+ + + Academy / {course.name} + +
+
+ {title} + {description} +
+
+ ); } \ No newline at end of file diff --git a/content/courses.tsx b/content/courses.tsx index 66d82407..7cbe6bc2 100644 --- a/content/courses.tsx +++ b/content/courses.tsx @@ -1,7 +1,7 @@ import { ArrowLeftRight, Blocks, CoinsIcon, Dice3, Dice3Icon, Mail, Sprout, SquareStack } from 'lucide-react'; -type Course = { +export type Course = { name: string; description: string; slug: string; From fad772393e612097fd923242a997b8e34235ed4c Mon Sep 17 00:00:00 2001 From: Martin Eckardt Date: Thu, 25 Jul 2024 10:26:00 +0200 Subject: [PATCH 2/2] Fix type --- app/layout.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/layout.tsx b/app/layout.tsx index 4866ccc2..0098914f 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -15,7 +15,7 @@ export const metadata = createMetadata({ }, // area for improvement: add page specific metadata - description: 'The Learning Platform for Avalanche Ecosystem', + description: 'The Learning Platform for the Avalanche Ecosystem', metadataBase: baseUrl, });