Files
crashtestdev/src/content.config.ts
T
Ken 2597afd472 feat: add content collection with schema and reading-time utility
- Created src/content.config.ts with Astro defineCollection using glob loader, pattern '**/*.{md,mdx}', base './src/content/posts', and Zod schema with 5 fields (title, date, type, tags, summary)
- Created src/content/posts/ directory for content storage
- Created src/utils/reading-time.ts with getReadingTime function (split whitespace, 200 WPM, Math.max(1, Math.ceil))
- All 23 new tests pass, all 61 total tests pass, npm run build succeeds

Generated with Amplifier

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
2026-05-26 23:03:44 +00:00

19 lines
475 B
TypeScript

import { defineCollection, z } from 'astro:content';
import { glob } from 'astro/loaders';
const posts = defineCollection({
loader: glob({
pattern: '**/*.{md,mdx}',
base: './src/content/posts',
}),
schema: z.object({
title: z.string(),
date: z.coerce.date(),
type: z.enum(['post', 'pattern', 'lesson']).default('post'),
tags: z.array(z.string()).default([]),
summary: z.string().optional(),
}),
});
export const collections = { posts };