website-astro/src/content/config.ts

42 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-12-22 11:18:44 +01:00
import { z, defineCollection } from "astro:content";
const articles = defineCollection({
schema: {
title: z.string(),
subtitle: z.string(),
lang: z.enum(["fr", "en"]),
2022-12-26 23:15:27 +01:00
slug: z.string(),
2022-12-22 11:18:44 +01:00
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,
},
});
const fragments = defineCollection({
schema: {
title: z.string(),
subtitle: z.string(),
lang: z.enum(["fr", "en"]),
slug: z.string(),
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,
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
};