import { stations } from "@/data";
import { getTrainStationSchema } from "@/lib/schemas";
import { notFound } from "next/navigation";
import StationGalleryClient from "./StationGalleryClient";

export function generateStaticParams() {
  return stations.map((station) => ({
    stationId: station.id,
  }));
}

export function generateMetadata({ params }) {
  const station = stations.find((s) => s.id === params.stationId);
  if (!station) return {};

  return {
    title: `${station.name} - Photo Gallery`,
    description: `${station.description} View photos and gallery of ${station.name}.`,
    keywords: [
      station.name,
      `${station.name} photos`,
      "Rajbari railway station",
      "Bangladesh Railway station",
    ],
    openGraph: {
      title: `${station.name} Gallery | Trains of Rajbari`,
      description: station.description,
      url: `https://trainsofrajbari.com/station/${station.id}`,
      images: [{ url: station.image }],
    },
    alternates: {
      canonical: `https://trainsofrajbari.com/station/${station.id}`,
    },
  };
}

export default function StationGalleryPage({ params }) {
  const station = stations.find((s) => s.id === params.stationId);
  if (!station) notFound();

  return (
    <>
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{
          __html: JSON.stringify(
            getTrainStationSchema({
              stationName: station.name,
              stationId: station.id,
              description: station.description,
              image: `https://trainsofrajbari.com${station.image}`,
            })
          ),
        }}
      />
      <StationGalleryClient station={station} />
    </>
  );
}
