mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-14 07:08:34 +00:00
25 lines
640 B
TypeScript
25 lines
640 B
TypeScript
import { defineCollection, z } from 'astro:content';
|
|
|
|
const blog = defineCollection({
|
|
// Type-check frontmatter using a schema
|
|
schema: z.object({
|
|
title: z.string(),
|
|
author: z.string(),
|
|
description: z.string().optional(),
|
|
// Transform string to Date object
|
|
date: z
|
|
.string()
|
|
.or(z.date())
|
|
.transform((val) => new Date(val)),
|
|
updatedDate: z
|
|
.string()
|
|
.optional()
|
|
.transform((str) => (str ? new Date(str) : undefined)),
|
|
image: z.string().optional(),
|
|
tags: z.array(z.string()).optional(),
|
|
draft: z.boolean().optional(),
|
|
}),
|
|
});
|
|
|
|
export const collections = { blog };
|