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>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user