website-astro/src/content/config.ts

42 lines
1.1 KiB
TypeScript

import { z, defineCollection } from "astro:content";
const articles = defineCollection({
schema: z.object({
title: z.string(),
subtitle: z.string(),
lang: z.enum(["fr", "en"]),
tags: z.array(z.string()), // An array of strings
// Parse pubDate as a browser-standard `Date` object
createdAt: z.string().transform((str) => new Date(str)),
updatedAt: z
.string()
.transform((str) => new Date(str))
.optional(),
code: z.boolean().optional() || false,
draft: z.boolean().optional() || false,
}),
});
const fragments = defineCollection({
schema: z.object({
title: z.string(),
subtitle: z.string(),
lang: z.enum(["fr", "en"]),
tags: z.array(z.string()), // An array of strings
// Parse pubDate as a browser-standard `Date` object
createdAt: z.string().transform((str) => new Date(str)),
updatedAt: z
.string()
.transform((str) => new Date(str))
.optional(),
code: z.boolean().optional() || false,
draft: z.boolean().optional() || false,
}),
});
export const collections = {
// Don't forget 'quotes' for collection names containing dashes
articles,
fragments,
};