65 lines
1.7 KiB
TypeScript
Executable file
65 lines
1.7 KiB
TypeScript
Executable file
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
|
|
type: z.string(),
|
|
permalink: z.string(),
|
|
// 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
|
|
type: z.string(),
|
|
permalink: z.string(),
|
|
// 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 references = defineCollection({
|
|
schema: z.object({
|
|
title: z.string(),
|
|
subtitle: z.string(),
|
|
url: z.string(),
|
|
lang: z.enum(["fr", "en"]),
|
|
permalink: 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,
|
|
draft: z.boolean().optional() || false,
|
|
}),
|
|
});
|
|
|
|
export const collections = {
|
|
// Don't forget 'quotes' for collection names containing dashes
|
|
articles,
|
|
fragments,
|
|
references,
|
|
};
|