Skip to content

Commit

Permalink
feat: add workshop metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphico committed Jun 17, 2024
1 parent d8d3532 commit 839d200
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/app/(app)/workshop/[workshopId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import * as React from "react"
import type { Metadata } from "next"
import { notFound, redirect } from "next/navigation"
import { env } from "@/env"
import { eq } from "drizzle-orm"

import { redirects } from "@/config/constants"
import { getUserSession } from "@/server/data/user"
import { getWorkshop } from "@/server/data/workshop"
import { db } from "@/server/db"
import { workshops } from "@/server/db/schema"
import { getExactScheduled } from "@/utils/format-scheduled-date"
import { Button } from "@/components/ui/button"
import { Separator } from "@/components/ui/separator"
Expand All @@ -22,6 +27,30 @@ interface WorkshopPageProps {
}
}

export async function generateMetadata({
params,
}: WorkshopPageProps): Promise<Metadata> {
const workshopId = decodeURIComponent(params.workshopId)

const workshop = await db.query.workshops.findFirst({
columns: {
title: true,
description: true,
},
where: eq(workshops.id, workshopId),
})

if (!workshop) {
return {}
}

return {
metadataBase: new URL(env.NEXT_PUBLIC_APP_URL),
title: workshop.title,
description: workshop.description,
}
}

export default async function WorkshopPage({ params }: WorkshopPageProps) {
const workshopId = decodeURIComponent(params.workshopId)

Expand Down

0 comments on commit 839d200

Please sign in to comment.