Files

27 lines
986 B
TypeScript
Raw Permalink Normal View History

import type { Metadata } from 'next'
import { db } from '@/lib/db'
import { tournaments } from '@/lib/db/schema'
import { eq } from 'drizzle-orm'
import { TournamentClient } from './client'
type Props = { params: Promise<{ year: string }> }
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { year: yearStr } = await params
const year = parseInt(yearStr)
const [t] = await db.select().from(tournaments).where(eq(tournaments.year, year)).limit(1)
const title = `${year} FIFA World Cup`
const description = t
? `${year} FIFA World Cup hosted by ${t.host}.${t.winner ? ` Winner: ${t.winner}.` : ''} Matches, scores, group standings and statistics.`
: `${year} FIFA World Cup — matches, scores and statistics.`
return {
title,
description,
openGraph: { title, description, url: `/tournaments/${year}` },
}
}
export default function TournamentPage({ params }: Props) {
return <TournamentClient params={params} />
}