ab.ncvp.me

an Astro site with mainly posts

Post collection schema

Posted on 10th May 2026 at 12:00 by Jane


content.config.ts

  schema: ({ image }) =>
    z.object({
      title: z.string(),

      // This must be an abstract. It will be used in lists of posts
      description: z.string(),

      // Transform string to Date object. Accepts a range of date formatas
      pubDate: z.coerce.date(),

      // String with default
      author: z.string().default("Admin"),

      // 1. Slugify categories
      categories: z
        // Must be one of these
        .array(
          z.enum(["misc", "test", "news", "dev", "admin", "edit", "images", "galleries", "text"]),
        )
        .default(["misc"])
        .transform((list) => list.map((item) => slugify(item))),

      // 2. Slugify tags
      tags: z
        .array(z.string())
        .default([])
        .transform((list) => list.map((item) => slugify(item))),

      // Optionally include request for file/page metadata
      showMeta: z.boolean().optional(),
    })

Category: misc Tags:

Rendered by src/pages/blog/[slug].astro