70 lines
1.7 KiB
TypeScript
70 lines
1.7 KiB
TypeScript
import { defineCollection, z } from "astro:content";
|
|
import { glob } from "astro/loaders";
|
|
|
|
// Petit helper pour éviter la répétition du loader
|
|
const obsidianLoader = (path: string) =>
|
|
glob({
|
|
pattern: "**/[^_]*.{md,mdx}",
|
|
base: `./src/content/${path}`,
|
|
});
|
|
|
|
const journal = defineCollection({
|
|
loader: obsidianLoader("journal"),
|
|
schema: z
|
|
.object({
|
|
title: z.string(),
|
|
// On rend la date plus flexible car Obsidian peut parfois envoyer des strings
|
|
publishDate: z.coerce.date(),
|
|
tags: z.array(z.string()).default([]),
|
|
author: z.string().default("Artisan"),
|
|
})
|
|
.passthrough(),
|
|
});
|
|
|
|
const classes = defineCollection({
|
|
loader: obsidianLoader("classes"),
|
|
schema: z
|
|
.object({
|
|
title: z.string(),
|
|
description: z.string(),
|
|
encre: z
|
|
.enum(["martial", "arcane", "divin", "primal", "hybride"])
|
|
.default("martial"),
|
|
})
|
|
.passthrough(),
|
|
});
|
|
|
|
const especes = defineCollection({
|
|
loader: obsidianLoader("especes"),
|
|
schema: z
|
|
.object({
|
|
title: z.string(),
|
|
description: z.string(),
|
|
spectre: z
|
|
.enum(["solaire", "elementaire", "terrestre", "sylvestre", "ombre"])
|
|
.default("terrestre"),
|
|
})
|
|
.passthrough(),
|
|
});
|
|
|
|
const personnages = defineCollection({
|
|
loader: obsidianLoader("personnages"),
|
|
schema: z
|
|
.object({
|
|
nom: z.string(),
|
|
espece: z.string(),
|
|
niveau_global: z.number().default(1),
|
|
classes_detail: z
|
|
.array(
|
|
z.object({
|
|
nom: z.string(),
|
|
niveau: z.number(),
|
|
}),
|
|
)
|
|
.default([]),
|
|
})
|
|
.passthrough(),
|
|
});
|
|
|
|
export const collections = { journal, classes, especes, personnages };
|