import { redirect, notFound } from "next/navigation";
import { getPostBySlug, postUrl } from "@/lib/wordpress";

// Redirect old /post/[slug] URLs to the new /{continent}/{country}/{category}/{slug} structure
export default async function OldPostRedirect({ params }: { params: { slug: string } }) {
  const post = await getPostBySlug(params.slug).catch(() => null);
  if (!post) notFound();
  redirect(postUrl(post));
}
