83 lines
2.6 KiB
TypeScript
83 lines
2.6 KiB
TypeScript
// src/content/config.ts
|
|
import { defineCollection, z } from 'astro:content';
|
|
|
|
// Define the post collection schema
|
|
const postsCollection = defineCollection({
|
|
type: 'content',
|
|
schema: z.object({
|
|
title: z.string(),
|
|
description: z.string().optional(),
|
|
pubDate: z.coerce.date(),
|
|
updatedDate: z.coerce.date().optional(),
|
|
heroImage: z.string().optional(),
|
|
|
|
// Support both single category and categories array
|
|
category: z.string().optional(),
|
|
categories: z.array(z.string()).optional(),
|
|
|
|
// Tags as an array
|
|
tags: z.array(z.string()).default([]),
|
|
|
|
// Author and reading time
|
|
author: z.string().optional(),
|
|
readTime: z.string().optional(),
|
|
|
|
// Draft status
|
|
draft: z.boolean().optional().default(false),
|
|
|
|
// Related posts by slug
|
|
related_posts: z.array(z.string()).optional(),
|
|
|
|
// Additional metadata
|
|
featured: z.boolean().optional().default(false),
|
|
technologies: z.array(z.string()).optional(),
|
|
complexity: z.enum(['beginner', 'intermediate', 'advanced']).optional(),
|
|
}),
|
|
});
|
|
|
|
// Define the configurations collection (for config files)
|
|
const configurationsCollection = defineCollection({
|
|
type: 'content',
|
|
schema: z.object({
|
|
title: z.string(),
|
|
description: z.string().optional(),
|
|
pubDate: z.coerce.date(),
|
|
updatedDate: z.coerce.date().optional(),
|
|
heroImage: z.string().optional(),
|
|
category: z.string().optional(),
|
|
categories: z.array(z.string()).optional(),
|
|
tags: z.array(z.string()).default([]),
|
|
technologies: z.array(z.string()).optional(),
|
|
complexity: z.enum(['beginner', 'intermediate', 'advanced']).optional(),
|
|
draft: z.boolean().optional().default(false),
|
|
version: z.string().optional(),
|
|
github: z.string().optional(),
|
|
}),
|
|
});
|
|
|
|
// Define the projects collection
|
|
const projectsCollection = defineCollection({
|
|
type: 'content',
|
|
schema: z.object({
|
|
title: z.string(),
|
|
description: z.string().optional(),
|
|
pubDate: z.coerce.date(),
|
|
updatedDate: z.coerce.date().optional(),
|
|
heroImage: z.string().optional(),
|
|
category: z.string().optional(),
|
|
categories: z.array(z.string()).optional(),
|
|
tags: z.array(z.string()).default([]),
|
|
technologies: z.array(z.string()).optional(),
|
|
github: z.string().optional(),
|
|
website: z.string().optional(),
|
|
status: z.enum(['concept', 'in-progress', 'completed', 'maintained']).optional(),
|
|
draft: z.boolean().optional().default(false),
|
|
}),
|
|
});
|
|
|
|
// Export the collections
|
|
export const collections = {
|
|
posts: postsCollection,
|
|
configurations: configurationsCollection,
|
|
projects: projectsCollection,
|
|
}; |