config.ts
1 import { defineCollection, z } from "astro:content"; 2 import { githubLoader } from "./loaders/github.ts"; 3 import { notesLoader } from "./loaders/notes.ts"; 4 5 const postCollection = defineCollection({ 6 schema: z.object({ 7 draft: z.boolean().optional().default(false), 8 title: z.string(), 9 date: z.coerce.date(), 10 description: z.string(), 11 tags: z.array(z.string()), 12 }), 13 }); 14 15 const projectCollection = defineCollection({ 16 schema: z.object({ 17 title: z.string(), 18 hasImage: z.boolean().default(true), 19 date: z.coerce.date(), 20 description: z.string(), 21 demo: z.string().nullable().default(null), 22 source: z.string(), 23 type: z.enum(["personal", "assignment", "open-source"]), 24 stack: z.array(z.tuple([z.string(), z.string()])), 25 featured: z.boolean().default(false), 26 }), 27 }); 28 29 const githubCollection = defineCollection({ 30 loader: githubLoader({ 31 username: "elianiva", 32 minStars: 5000, 33 }), 34 }); 35 36 const notesCollection = defineCollection({ 37 loader: notesLoader(), 38 }); 39 40 export const collections = { 41 projects: projectCollection, 42 posts: postCollection, 43 notes: notesCollection, 44 github: githubCollection, 45 };