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

const products = defineCollection({
  loader: glob({ pattern: '**/*.{md,mdx}', base: './src/content/products' }),
  schema: z.object({
    title: z.string(),
    description: z.string(),
    category: z.enum([
      'transparenta',
      'comunicare',
      'cereri',
      'educatie',
      'ai',
    ]),
    author: z.string(),
    authorLocation: z.string().optional(),
    authorGithub: z.string().optional(),
    demoUrl: z.string().optional(),
    sourceUrl: z.string().optional(),
    screenshot: z.string().optional(),
    status: z.enum(['listed', 'demo', 'verified']).default('listed'),
    tags: z.array(z.string()).default([]),
    publishedAt: z.date(),
    solvesProblems: z.array(z.string()).default([]),
    difficulty: z.enum(['easy', 'medium', 'hard']).optional(),
    impact: z.enum(['low', 'medium', 'high', 'critical']).optional(),
  }),
});

export const collections = { products };
