Astro Content Collections
Required schema fields
Section titled “Required schema fields”Add these fields to your posts collection in src/content.config.ts:
import { defineCollection, z } from 'astro:content';
const posts = defineCollection({ schema: z.object({ title: z.string(), date: z.coerce.date(), author: z.string().default(''), categories: z.array(z.string()).default([]), tags: z.array(z.string()).default([]), feature_image: z.string().optional(), draft: z.boolean().default(false), }),});
export const collections = { posts };Why categories must be an array
Section titled “Why categories must be an array”scribe writes categories as a YAML array even when only one is selected:
categories: - reviewUsing z.string() instead of z.array(z.string()) will cause build failures.