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

import { glob, file } from "astro/loaders";

const strings = defineCollection({
    loader: glob({ pattern: "*.toml", base: "./src/data/strings" })
});

const commonPages = defineCollection({
    loader: glob({ pattern: "**/*.mdx", base: "./src/data/common" }),
    schema: z.object({
        title: z.string(),
        description: z.string().optional(),
    })
});

const distroGuide = defineCollection({
    loader: glob({ pattern: "**/*.mdx", base: "./src/data/distro" }),
    schema: z.object({
        title: z.string(),
        description: z.string().optional(),
        aliasOf: z.string().optional(),
        continueTo: z.string().optional(),
    })
});

const distroQuiz = defineCollection({
    loader: glob({ pattern: "*.toml", base: "./src/data/distroquiz" }),
    schema: z.object({
        dialogs: z.array(z.object({
            title: z.string(),
            content: z.string(),
            choices: z.array(z.object({
                text: z.string(),
                action: z.string(),
                data: z.string().or(z.number()).optional(),
            })),
        })),
    })
});

export const collections = { strings, commonPages, distroGuide, distroQuiz };
