// Central post registry. Every post is listed here and referenced by slug.
// Keeping metadata in one place lets the index page and sitemap share a
// single source of truth without parsing MDX frontmatter at build time.

export type Post = {
  slug: string;
  title: string;
  description: string;
  /** ISO date string (YYYY-MM-DD). Drives ordering + sitemap lastModified. */
  date: string;
  author: string;
  /** Rough reading time in minutes — shown on the index card. */
  readingMinutes: number;
};

export const posts: Post[] = [
  {
    slug: "send-email-from-python-agent",
    title: "Send real email from a Python AI agent in 20 lines",
    description:
      "A minimal walkthrough: give your Python agent an email address, send verified mail, receive replies via webhook or WebSocket, and thread the whole conversation.",
    date: "2026-04-13",
    author: "e2a",
    readingMinutes: 5,
  },
  {
    slug: "email-for-openclaw-agents",
    title: "Give your OpenClaw agent an email address (with real-time WebSocket delivery)",
    description:
      "OpenClaw runs locally, so by default it has no public inbox. This tutorial wires it to a real email address via e2a — WebSocket delivery, no public URL, under 5 minutes.",
    date: "2026-04-19",
    author: "e2a",
    readingMinutes: 5,
  },
  {
    slug: "human-in-the-loop-for-agent-email",
    title: "Human-in-the-loop: approve before your agent hits send",
    description:
      "Per-agent approval for outbound AI email. Flip one switch; the next time your agent tries to send, you get a notification with approve / reject buttons. Review in the dashboard, CLI, or straight from your inbox.",
    date: "2026-04-24",
    author: "e2a",
    readingMinutes: 6,
  },
  {
    slug: "email-agent-with-google-adk",
    title: "Give your Google ADK agent an email inbox (with conversation memory)",
    description:
      "Wire a Google Agent Development Kit agent to a real email address. HMAC-verified webhooks, multi-turn memory across email replies via the conversation_id ↔ ADK session_id binding, ~30 lines of business logic. Full runnable example included.",
    date: "2026-04-27",
    author: "e2a",
    readingMinutes: 7,
  },
];

export function getPost(slug: string): Post | undefined {
  return posts.find((p) => p.slug === slug);
}

export function getPostsSortedByDate(): Post[] {
  return [...posts].sort((a, b) => (a.date < b.date ? 1 : -1));
}
