45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
|
|
import type { Metadata } from "next"
|
||
|
|
import { PublicOrderOfMerit } from "@/components/public-order-of-merit"
|
||
|
|
|
||
|
|
// Server-side -- går IKKE gjennom next.config.mjs sin rewrites() (kun for
|
||
|
|
// nettleser-trafikk inn til Next.js-serveren). Peker direkte på API-et.
|
||
|
|
const API_ORIGIN = process.env.TEECUP_API_ORIGIN || "http://localhost:8000"
|
||
|
|
|
||
|
|
type PublicOomInfo = {
|
||
|
|
name: string
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function generateMetadata({
|
||
|
|
params,
|
||
|
|
}: {
|
||
|
|
params: Promise<{ id: string }>
|
||
|
|
}): Promise<Metadata> {
|
||
|
|
const { id } = await params
|
||
|
|
try {
|
||
|
|
const res = await fetch(`${API_ORIGIN}/public/order-of-merits/${id}`, { cache: "no-store" })
|
||
|
|
if (!res.ok) {
|
||
|
|
return { title: "Order of Merit | TeeCup" }
|
||
|
|
}
|
||
|
|
const data: PublicOomInfo = await res.json()
|
||
|
|
const title = `${data.name} | TeeCup`
|
||
|
|
const description = `Se resultatlisten for ${data.name} på TeeCup.`
|
||
|
|
return {
|
||
|
|
title,
|
||
|
|
description,
|
||
|
|
openGraph: { title, description, siteName: "TeeCup", type: "website" },
|
||
|
|
twitter: { card: "summary", title, description },
|
||
|
|
}
|
||
|
|
} catch {
|
||
|
|
return { title: "TeeCup" }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export default async function PublicOrderOfMeritPage({
|
||
|
|
params,
|
||
|
|
}: {
|
||
|
|
params: Promise<{ id: string }>
|
||
|
|
}) {
|
||
|
|
const { id } = await params
|
||
|
|
return <PublicOrderOfMerit oomId={id} />
|
||
|
|
}
|