import { defineCollection } from "astro:content"; import { glob } from "astro/loaders"; // Not astro:content's re-export, which is deprecated. import { z } from "astro/zod"; /** * Posts are markdown files, and the schema is what stops a typo in the * frontmatter from shipping as a page with no date on it. * * The field names are the ones standard.site publishing tools already look * for - title, description, publishDate, tags, draft - so posting these to an * ATProto repository later is a matter of pointing something at this * directory, not of renaming every file's frontmatter. atUri is the other * direction: it is what those tools write back once a post has a record. */ const blog = defineCollection({ loader: glob({ base: "./src/content/blog", pattern: "**/*.md" }), schema: z.object({ title: z.string(), description: z.string(), publishDate: z.coerce.date(), updatedDate: z.coerce.date().optional(), tags: z.array(z.string()).default([]), draft: z.boolean().default(false), // The post's own record, written back here by whatever publishes it. It // is absent until then, and a post without one renders no standard.site // link tag rather than an empty href. atUri: z.string().startsWith("at://").optional(), }), }); export const collections = { blog };