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

const series = defineCollection({
  loader: glob({ pattern: '**/*.md', base: './src/content/series' }),
  schema: ({ image }) => z.object({
    index: z.number(),
    category: z.enum(['mariage', 'portrait-lifestyle', 'reportage-editorial', 'evenementiel']),
    title: z.string(),
    lieu: z.string(),
    date: z.string(),
    // mariage-specific fields, optional
    couple: z.string().optional(),
    invites: z.number().optional(),
    formule: z.enum(['demi-journee', 'journee-complete', 'sur-mesure']).optional(),
    // generic fields
    client: z.string().optional(),
    duree: z.string().optional(),
    cover: image(),
    coverAlt: z.string(),
    excerpt: z.string().max(220),
    published: z.boolean().default(true),
    order: z.number().optional(),
  }),
});

export const collections = { series };
