import CheckView from "@/components/views/CheckView"; import PageRuntime from "@/components/PageRuntime"; import { BreadcrumbJsonLd, BusRouteJsonLd } from "@/components/JsonLd"; import { SITE_NAME } from "@/lib/site"; import { api } from "@/lib/api"; import type { Metadata } from "next"; type Params = { params: Promise<{ routeId: string }> }; async function loadRoute(id: string) { try { return await api.route(decodeURIComponent(id)); } catch { return null; } } export async function generateMetadata({ params }: Params): Promise { const { routeId } = await params; const r = await loadRoute(routeId); if (!r) { return { title: "เช็กเวลาเดินรถ", alternates: { canonical: `/check/${routeId}` } }; } const title = `เวลาเดินรถ สาย ${r.route_id} ${r.name_th || ""}`.trim(); const description = `ตารางเวลาเดินรถสาย ${r.route_id} ${r.name_th || ""} ทั้งวันทำการและวันหยุด ` + `พร้อมเวลารถออกจากแต่ละจุดจอด — ${SITE_NAME}`; return { title, description, alternates: { canonical: `/check/${encodeURIComponent(r.route_id)}` }, openGraph: { type: "article", title, description, url: `/check/${encodeURIComponent(r.route_id)}` }, }; } export default async function Page({ params }: Params) { const { routeId } = await params; const r = await loadRoute(routeId); return ( <> {r ? ( <> ) : null} ); }