import { defineCollection, z } from 'astro:content';

const blog = defineCollection({
  type: 'content',
  schema: z.object({
    title: z.string(),
    description: z.string(),
    // Optional SEO overrides. When set they drive the <title> tag and
    // <meta name="description"> without changing the on-page article
    // heading/excerpt, letting us keep descriptive H1s while tuning the
    // search snippet to the 50–60 / 150–160 character sweet spots.
    // `seoTitle` is the text BEFORE the " | WorkRoot" brand suffix.
    seoTitle: z.string().optional(),
    seoDescription: z.string().optional(),
    pubDate: z.coerce.date(),
    updatedDate: z.coerce.date().optional(),
    heroImage: z.string().optional(),
    category: z.enum(['Web Development', 'Mobile Apps', 'AI/ML', 'Cloud', 'DevOps', 'Security']),
    tags: z.array(z.string()),
    author: z.object({
      name: z.string(),
      avatar: z.string().optional(),
    }),
    draft: z.boolean().default(false),
  }),
});

export const collections = { blog };
