import { defineCollection, z } from "astro:content";
import { glob } from "astro/loaders";

const articleSchema = z.object({
  title: z.string(),
  slug: z.string(),
  date: z.coerce.date(),
  updated: z.coerce.date(),
  category: z.string(),
  author: z.string(),
  excerpt: z.string(),
  status: z.enum(["draft", "published"]),
});

const articles = defineCollection({
  loader: glob({ pattern: "**/*.md", base: "./src/content/articles" }),
  schema: articleSchema,
});

const published = defineCollection({
  loader: glob({ pattern: "**/*.md", base: "./src/content/published" }),
  schema: articleSchema,
});

export const collections = { articles, published };
