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

const projects = defineCollection({
    loader: file("src/content/projects/projects.yml"),
    schema: z.object({
        slug: z.string(),
        name: z.string(),
        description: z.string(),
        date: z.date(),
        dateVisual: z.string().optional(),
        links: z.string().array()
    })
});

const badges = defineCollection({
    loader: file("src/content/badges/badges.yml"),
    schema: ({ image }) => z.object({
        slug: z.string(),
        // oh my god lol
        // most scuffed way to do this
        path: z.string().startsWith("/").or(image()),
        alt: z.string(),
        href: z.string().optional(),
        title: z.string().optional()
    })
});

export const collections = { projects, badges };
