import { defineCollection } from "astro:content";
import { docsLoader } from "@astrojs/starlight/loaders";
import { docsSchema } from "@astrojs/starlight/schema";
import { file } from "astro/loaders";
import { z } from "zod";

export const collections = {
  docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
  vocabList: defineCollection({
    loader: file("src/vocab_list.yaml"),
    schema: z.object({
      about: z.string().optional(),
      words: z.array(
        z.object({
          type: z.string(),
          english: z.string(),
          hindi: z.string(),
          gender: z.enum(["m", "f"]).optional(),
          note: z.string().optional(),
          examples: z
            .array(
              z.object({
                english: z.string(),
                hindi: z.string(),
                note: z.string().optional(),
              }),
            )
            .optional(),
          see_also: z.array(z.string()).optional(),
        }),
      ),
    }),
  }),
};
