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

const references = defineCollection({
  loader: glob({ pattern: '**/*.md', base: './src/content/references' }),
  schema: z.object({
    title: z.string(),
    category: z.enum(['Kundenarbeiten', 'Umbauten', 'Neubauten', 'Sanierungen', 'Baumeisterarbeiten']),
    audience: z.array(z.enum(['Privatkundschaft', 'Architekten', 'Gewerbe', 'Öffentlich'])).default(['Privatkundschaft']),
    location: z.string(),
    year: z.string(),
    services: z.array(z.string()),
    architect: z.string().optional(),
    summary: z.string(),
    heroImage: z.string(),
    gallery: z.array(z.string()).default([]),
    projectType: z.string().optional(),
    situation: z.string().optional(),
    challenge: z.string().optional(),
    solution: z.string().optional(),
    result: z.string().optional(),
    featured: z.boolean().default(false),
  }),
});

const news = defineCollection({
  loader: glob({ pattern: '**/*.md', base: './src/content/news' }),
  schema: z.object({
    title: z.string(),
    date: z.date(),
    category: z.enum(['Neuigkeit', 'Projektupdate', 'Betriebsferien', 'Referenz', 'Stelle', 'Lehrstelle']),
    summary: z.string(),
    image: z.string().optional(),
    published: z.boolean().default(true),
  }),
});

const team = defineCollection({
  loader: glob({ pattern: '**/*.md', base: './src/content/team' }),
  schema: z.object({
    name: z.string(),
    role: z.string(),
    photo: z.string().optional(),
    shortBio: z.string(),
    email: z.string().email().optional(),
    phone: z.string().optional(),
    placeholder: z.boolean().default(false),
  }),
});

export const collections = { references, news, team };
