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

const blog = defineCollection({
    type: "content",
    schema: z.object({
        title: z.string(),
        description: z.string(),
        pubDate: z.coerce.date(),
        tags: z.array(z.string()).default([]),
        category: z.string().optional(),
        featuredEssay: z.boolean().optional().default(false),
        readingOrder: z.number().int().positive().optional(),
        series: z
            .object({
                name: z.string(),
                part: z.number().int().positive(),
            })
            .optional(),
        draft: z.boolean().optional().default(false),
        audio: z.boolean().optional().default(false),
    }),
});

const coffee = defineCollection({
    type: "content",
    schema: z.object({
        title: z.string().optional(),
        date: z.coerce.date(),
        draft: z.boolean().optional().default(false),
    }),
});

const links = defineCollection({
    type: "content",
    schema: z.object({
        title: z.string(),
        url: z.string().url(),
        description: z.string(),
        category: z.string().optional(),
        date: z.coerce.date().optional(),
        draft: z.boolean().optional().default(false),
    }),
});

export const collections = { blog, coffee, links };
