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

const news = defineCollection({
    loader: glob({ pattern: "**/*.md", base: "./src/content/news" }),
    schema: ({ image }) => z.object({
        locale: z.string().describe("News main language"),
        title: z.string(),
        date: z.date(),
        draft: z.boolean().optional(),
        place: z.string().optional(),
        order: z.number().optional(),
        city: z.string().optional(),
        state: z.string().optional(),
        country: z.string().optional(),
        thumbnail: image().optional().describe("Main news thumbnail image"),
        youtube: z.string().optional(),
        gallery: z.array(z.object({
            image: image().optional(),
            text: z.string().optional()
        })).optional().nullable()
    }),
});

export const collections = { news };