Adjust config to be compatible with the CMS

This commit is contained in:
Maciej Pędzich 2023-04-26 10:21:53 +02:00
parent 6f99ef7a57
commit 1cf7ade0ce

View File

@ -1,21 +1,16 @@
import { defineCollection, z } from 'astro:content';
const blog = defineCollection({
// Type-check frontmatter using a schema
schema: z.object({
title: z.string(),
description: z.string(),
// Transform string to Date object
pubDate: z
.string()
.or(z.date())
.transform((val) => new Date(val)),
updatedDate: z
.string()
.optional()
.transform((str) => (str ? new Date(str) : undefined)),
heroImage: z.string().optional(),
}),
schema: z.object({
title: z.string(),
description: z.string(),
draft: z.boolean().optional().default(true),
pubDate: z
.string()
.or(z.date())
.transform((val) => new Date(val)),
categories: z.enum(['Dev Journal', 'Miscellaneous']).array()
})
});
export const collections = { blog };