-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.config.ts
More file actions
42 lines (38 loc) · 1.12 KB
/
content.config.ts
File metadata and controls
42 lines (38 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob, file } from 'astro/loaders';
const posts = defineCollection({
loader: glob({ pattern: '**/*.md', base: './src/content/posts' }),
schema: ({ image }) =>
z.object({
title: z.string(),
author: z.array(z.string()),
tags: z.array(z.string()).optional(),
image: image().optional(),
date: z.coerce.date(),
draft: z.boolean().default(false),
excerpt: z.string().nullable().optional(),
}),
});
const authors = defineCollection({
loader: file('src/data/authors.yaml'),
schema: z.object({
id: z.string(),
avatar: z.string(),
bio: z.string(),
twitter: z.string().optional(),
facebook: z.string().optional(),
website: z.url().optional(),
location: z.string().optional(),
profile_image: z.string().optional(),
}),
});
const tags = defineCollection({
loader: file('src/data/tags.yaml'),
schema: z.object({
id: z.string(),
description: z.string().optional(),
image: z.string().optional(),
}),
});
export const collections = { posts, authors, tags };