// @ts-ignore
import {defineCollection, reference, z} from 'astro:content';

export const pages = defineCollection({
    type: "content",
    schema: z.object({
        title: z.string().min(1).max(80),
        description: z.string().min(1).max(120),
        image: z.string().optional()
    })
})

export const help = defineCollection({
    type: "content",
    schema: z.object({
        title: z.string().min(1).max(80),
        description: z.string().min(1).max(120),
        tags: z.array(z.string()),
        related: z.array(reference('help')).optional()
    })
})

export const modes = defineCollection({
    type: "data",
    schema: z.object({
        translationKey: z.string(),
        main: z.boolean(),
        ranked: z.boolean().optional().default(false)
    })
})

export const downloads = defineCollection({
    type: "data",
    schema: z.object({
        name: z.string(),
        description: z.string(),
        url: z.string().url()
            .or(z.record(z.string(), z.string())),
        sourceUrl: z.string().url().optional(),
    })
})

export const rules = defineCollection({
    type: "content",
    schema: z.object({

    })
})

export const announcements = defineCollection({
    type: "content",
    schema: ({image}) => z.object({
        title: z.string(),
        description: z.string(),
        image: image().optional(),
        tags: z.array(z.string()),
        created: z.date()
    })
})

export const collections = {
    'pages': pages,
    'help': help,
    'modes': modes,
    'rules': rules,
    'downloads': downloads,
    'announcements': announcements
}
