website-astro/src/content/config.ts

63 lines
1.6 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
2023-05-09 12:26:03 +02:00
type: z.string(),
2022-12-22 11:18:44 +01:00
// 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
2023-05-09 12:26:03 +02:00
type: z.string(),
2022-12-28 10:36:15 +01:00
// 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
});
2023-04-19 18:24:40 +02:00
const references = defineCollection({
schema: z.object({
title: z.string(),
subtitle: z.string(),
url: 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,
}),
});
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,
2023-04-19 18:24:40 +02:00
references,
2022-12-22 11:18:44 +01:00
};