import type { Metadata } from "next";
import { PostForm } from "@/components/admin/PostForm";
import { emptyPostForm } from "@/lib/form";
import { getAllPosts } from "@/lib/cms";

export const metadata: Metadata = {
  title: "New journal post",
  robots: { index: false, follow: false },
};

export default async function NewPostPage() {
  const posts = await getAllPosts();
  const categories = [...new Set(posts.map((p) => p.category))];

  return (
    <div className="space-y-8">
      <header>
        <p className="text-sm font-semibold uppercase tracking-[0.14em] text-coral">
          Content
        </p>
        <h1 className="display-2 mt-2">New journal post</h1>
        <p className="mt-2 text-ink-soft">
          Write the article, add a cover image, and tune the SEO before you publish.
        </p>
      </header>

      <PostForm initial={emptyPostForm()} categories={categories} mode="new" />
    </div>
  );
}
