website-astro/src/content/config.ts

42 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-12-22 11:18:44 +01:00
import { z, defineCollection } from "astro:content";
const articles = defineCollection({
2023-02-03 11:21:01 +01:00
schema: z.object({
2022-12-22 11:18:44 +01:00
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
2022-12-28 10:36:15 +01:00
createdAt: z.string().transform((str) => new Date(str)),
updatedAt: z
2022-12-22 11:18:44 +01:00
.string()
.transform((str) => new Date(str))
.optional(),
2022-12-28 10:36:15 +01:00
code: z.boolean().optional() || false,
2023-02-03 10:37:28 +01:00
draft: z.boolean().optional() || false,
2023-02-03 11:21:01 +01:00
}),
2022-12-28 10:36:15 +01:00
});
const fragments = defineCollection({
2023-02-03 11:21:01 +01:00
schema: z.object({
2022-12-28 10:36:15 +01:00
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,
2023-02-03 10:37:28 +01:00
draft: z.boolean().optional() || false,
2023-02-03 11:21:01 +01:00
}),
2022-12-22 11:18:44 +01:00
});
export const collections = {
// Don't forget 'quotes' for collection names containing dashes
articles,
2022-12-28 10:36:15 +01:00
fragments,
2022-12-22 11:18:44 +01:00
};