classe et espece
This commit is contained in:
44
src/content/config.ts
Normal file
44
src/content/config.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
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(),
|
||||
})
|
||||
.passthrough(),
|
||||
});
|
||||
|
||||
const especes = defineCollection({
|
||||
loader: obsidianLoader("especes"),
|
||||
schema: z
|
||||
.object({
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
})
|
||||
.passthrough(),
|
||||
});
|
||||
|
||||
export const collections = { journal, classes, especes };
|
||||
Reference in New Issue
Block a user