import { defineCollection, z } from 'astro:content';
import { glob } from 'astro/loaders';

const bujo = defineCollection({
	loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: "./src/content/bujo" }),
	schema: z.object({
		title: z.string(),
		publishDate: z.date(),
	}).passthrough(),
});

const codex = defineCollection({
	loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: "./src/content/codex" }),
	schema: z.object({}).passthrough(), // TODO: Définir un schéma plus strict
});

const journal = defineCollection({
	loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: "./src/content/journal" }),
	schema: z.object({
		title: z.string(),
		author: z.string(),
		publishDate: z.date(),
		tags: z.array(z.string()),
	}).passthrough(),
});

const logs = defineCollection({
	loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: "./src/content/logs" }),
	schema: z.object({
		title: z.string(),
		publishDate: z.date(),
		tags: z.array(z.string()),
	}).passthrough(),
});

export const collections = { bujo, codex, journal, logs };