Fork of Chiri for Astro for my blog
1import { glob } from 'astro/loaders'
2import { defineCollection, z } from 'astro:content'
3
4const posts = defineCollection({
5 // Load Markdown and MDX files in the `src/content/posts/` directory.
6 loader: glob({ base: './src/content/posts', pattern: '**/*.{md,mdx}' }),
7 // Type-check frontmatter using a schema
8 schema: () =>
9 z.object({
10 title: z.string(),
11 // Transform string to Date object
12 pubDate: z.coerce.date(),
13 image: z.string().optional(),
14 atUri: z.string().optional()
15 })
16})
17
18const about = defineCollection({
19 // Load Markdown files in the `src/content/about/` directory.
20 loader: glob({ base: './src/content/about', pattern: '**/*.md' }),
21 // Type-check frontmatter using a schema
22 schema: z.object({})
23})
24
25export const collections = { posts, about }