Skip to content

Commit 839d200

Browse files
committed
feat: add workshop metadata
1 parent d8d3532 commit 839d200

File tree

1 file changed

+29
-0
lines changed
  • src/app/(app)/workshop/[workshopId]

1 file changed

+29
-0
lines changed

src/app/(app)/workshop/[workshopId]/page.tsx

+29
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import * as React from "react"
2+
import type { Metadata } from "next"
23
import { notFound, redirect } from "next/navigation"
4+
import { env } from "@/env"
5+
import { eq } from "drizzle-orm"
36

47
import { redirects } from "@/config/constants"
58
import { getUserSession } from "@/server/data/user"
69
import { getWorkshop } from "@/server/data/workshop"
10+
import { db } from "@/server/db"
11+
import { workshops } from "@/server/db/schema"
712
import { getExactScheduled } from "@/utils/format-scheduled-date"
813
import { Button } from "@/components/ui/button"
914
import { Separator } from "@/components/ui/separator"
@@ -22,6 +27,30 @@ interface WorkshopPageProps {
2227
}
2328
}
2429

30+
export async function generateMetadata({
31+
params,
32+
}: WorkshopPageProps): Promise<Metadata> {
33+
const workshopId = decodeURIComponent(params.workshopId)
34+
35+
const workshop = await db.query.workshops.findFirst({
36+
columns: {
37+
title: true,
38+
description: true,
39+
},
40+
where: eq(workshops.id, workshopId),
41+
})
42+
43+
if (!workshop) {
44+
return {}
45+
}
46+
47+
return {
48+
metadataBase: new URL(env.NEXT_PUBLIC_APP_URL),
49+
title: workshop.title,
50+
description: workshop.description,
51+
}
52+
}
53+
2554
export default async function WorkshopPage({ params }: WorkshopPageProps) {
2655
const workshopId = decodeURIComponent(params.workshopId)
2756

0 commit comments

Comments
 (0)