diff --git a/frontend/public/locales/en.json b/frontend/public/locales/en.json index 238d518..233ecce 100644 --- a/frontend/public/locales/en.json +++ b/frontend/public/locales/en.json @@ -89,7 +89,7 @@ "home.lead": "Browse routes, find stops, and preview a route right from this page", "home.chooseProvince": "Select Province", "home.chooseStation": "Select Terminal", - "share.label": "Share short link", + "share.label": "Share this page", "share.copied": "Link copied", "share.short": "Short link", "share.line": "Share on LINE", diff --git a/frontend/public/locales/th.json b/frontend/public/locales/th.json index 7f9638c..c98fecf 100644 --- a/frontend/public/locales/th.json +++ b/frontend/public/locales/th.json @@ -89,7 +89,7 @@ "home.lead": "ดูสายรถ, ค้นหาป้าย และเปิดตัวอย่างเส้นทางได้ทันทีจากหน้าแรก", "home.chooseProvince": "เลือกจังหวัด", "home.chooseStation": "เลือกสถานีขนส่งผู้โดยสาร", - "share.label": "แชร์ลิงก์สั้น", + "share.label": "แชร์หน้านี้", "share.copied": "คัดลอกลิงก์แล้ว", "share.short": "ลิงก์สั้น", "share.line": "แชร์ผ่าน LINE", diff --git a/frontend/src/app/about/page.tsx b/frontend/src/app/about/page.tsx index 1ca5791..81e61bc 100644 --- a/frontend/src/app/about/page.tsx +++ b/frontend/src/app/about/page.tsx @@ -1,7 +1,11 @@ import AboutView from "@/components/views/AboutView"; import PageRuntime from "@/components/PageRuntime"; -export const metadata = { title: "เกี่ยวกับเรา" }; +export const metadata = { + title: "เกี่ยวกับเรา", + description: "Atroute — แหล่งรวมข้อมูลรถโดยสารจังหวัดอ่างทอง", + alternates: { canonical: "/about" }, +}; export default function Page() { return ( diff --git a/frontend/src/app/blog/page.tsx b/frontend/src/app/blog/page.tsx index da2f142..d1fc32a 100644 --- a/frontend/src/app/blog/page.tsx +++ b/frontend/src/app/blog/page.tsx @@ -1,7 +1,11 @@ import BlogView from "@/components/views/BlogView"; import PageRuntime from "@/components/PageRuntime"; -export const metadata = { title: "บ่นไปเรื่อย" }; +export const metadata = { + title: "บ่นไปเรื่อย", + description: "บทความและเรื่องเล่าเกี่ยวกับการเดินทางด้วยรถโดยสารในจังหวัดอ่างทอง", + alternates: { canonical: "/blog" }, +}; export default function Page() { return ( diff --git a/frontend/src/app/check/[routeId]/page.tsx b/frontend/src/app/check/[routeId]/page.tsx index d4acf77..fd5a3f0 100644 --- a/frontend/src/app/check/[routeId]/page.tsx +++ b/frontend/src/app/check/[routeId]/page.tsx @@ -1,12 +1,61 @@ 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"; -export const metadata = { title: "เช็กเวลาเดินรถ" }; +type Params = { params: Promise<{ routeId: string }> }; -export default async function Page({ 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} diff --git a/frontend/src/app/credits/page.tsx b/frontend/src/app/credits/page.tsx index fb7154c..af16ab7 100644 --- a/frontend/src/app/credits/page.tsx +++ b/frontend/src/app/credits/page.tsx @@ -1,6 +1,10 @@ import CreditsView from "@/components/views/CreditsView"; -export const metadata = { title: "เครดิต" }; +export const metadata = { + title: "เครดิต", + description: "แหล่งที่มาของข้อมูล รูปภาพ ฟอนต์ และซอฟต์แวร์ที่ใช้บนเว็บนี้", + alternates: { canonical: "/credits" }, +}; export default function Page() { return ;} diff --git a/frontend/src/app/layout.tsx b/frontend/src/app/layout.tsx index 2302f13..ff04dc4 100644 --- a/frontend/src/app/layout.tsx +++ b/frontend/src/app/layout.tsx @@ -1,4 +1,6 @@ import type { Metadata, Viewport } from "next"; +import { SITE_URL, SITE_NAME, SITE_TITLE, SITE_DESCRIPTION, SITE_LOCALE, SITE_OG_IMAGE } from "@/lib/site"; +import { SiteJsonLd } from "@/components/JsonLd"; import IconSprite from "@/components/IconSprite"; import PwaBoot from "@/components/PwaBoot"; import SiteBoot from "@/components/SiteBoot"; @@ -15,13 +17,64 @@ import "@/styles/responsive.css"; // (router เดิม inject