website-astro/src/content/config.ts

27 lines
712 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { z, defineCollection } from "astro:content";
const articles = defineCollection({
slug: ({ defaultSlug, data }) => {
// Use `permalink` from the entrys frontmatter as the slug, if it exists.
// Otherwise, fall back to the default slug.
return data.slug || defaultSlug;
},
schema: {
title: z.string(),
subtitle: z.string(),
lang: z.enum(["fr", "en"]),
slug: z.string().optional(),
tags: z.array(z.string()), // An array of strings
// Parse pubDate as a browser-standard `Date` object
pubDate: z
.string()
.transform((str) => new Date(str))
.optional(),
},
});
export const collections = {
// Don't forget 'quotes' for collection names containing dashes
articles,
};