← Back to Blog

Astro Content Collections

#astro #mdx #content

Astro Content Collections

Using typed schemas keeps content safer and easier to query.

import { defineCollection, z } from 'astro:content';

const blog = defineCollection({
  type: 'content',
  schema: z.object({
    title: z.string(),
    description: z.string(),
    date: z.date(),
    tags: z.array(z.string()),
  }),
});

export const collections = { blog };