diff --git a/src/app/themes/[theme]/page.tsx b/src/app/themes/[theme]/page.tsx index 69d150a..e957cc0 100644 --- a/src/app/themes/[theme]/page.tsx +++ b/src/app/themes/[theme]/page.tsx @@ -5,8 +5,40 @@ import ThemePage from "@/components/theme-page"; import { getAllThemes, getThemeFromId } from "@/lib/themes"; import { Metadata, ResolvingMetadata } from "next"; +export async function generateMetadata( + { params, searchParams }: any, + parent: ResolvingMetadata +): Promise { + const theme = params.theme + const themeData = await getThemeFromId(theme); + if (!themeData) { + return { + title: "Theme not found", + description: "Theme not found", + }; + } + return { + title: themeData.name, + description: themeData.description, + keywords: [themeData.name, themeData.description], + openGraph: { + title: themeData.name, + description: themeData.description, + images: [ + { + url: themeData.image, + width: 500, + height: 500, + alt: themeData.name, + }, + ], + }, + }; +} + export async function generateStaticParams() { const themes = await getAllThemes(); + console.log(themes); return themes.map((theme) => ({ theme: theme.id, })); diff --git a/src/components/theme-page.tsx b/src/components/theme-page.tsx index 7e3d619..4b605a7 100644 --- a/src/components/theme-page.tsx +++ b/src/components/theme-page.tsx @@ -1,4 +1,4 @@ -"use client"; + import Image from "next/image"; import { getThemeAuthorLink, getThemeFromId, getThemeMarkdown, ZenTheme } from "@/lib/themes"; import { Button } from "./ui/button"; @@ -19,10 +19,10 @@ export default async function ThemePage({ themeID }: { themeID: string }) { return (
-
window.history.back()}> +

Go back

-
+ {theme.name}

{theme.name}

{theme.description}