-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
58 lines (54 loc) · 1.99 KB
/
config.ts
File metadata and controls
58 lines (54 loc) · 1.99 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { defineCollection, reference, z } from 'astro:content';
import { glob } from 'astro/loaders';
const authors = defineCollection({
loader: glob({ pattern: '**/*.json', base: './src/content/authors' }),
schema: z.object({
name: z.string(),
bio: z.string().optional(),
role: z.string().optional().default('contributor'),
avatar: z.string().optional(),
github: z.string().optional(),
twitter: z.string().optional(),
linkedin: z.string().optional(),
mastodon: z.string().optional(),
bluesky: z.string().optional(),
website: z.string().optional(),
email: z.string().email().optional(),
}),
});
const posts = defineCollection({
loader: glob({ pattern: '**/index.{md,mdx}', base: './src/content/posts' }),
schema: ({ image }) =>
z.object({
title: z.string(),
summary: z.string(),
authors: z.array(reference('authors')).min(1),
date: z.coerce.date(),
readMin: z.number().int().positive(),
topic: z.string(),
topicId: z.string(),
tags: z.array(z.string()).optional(),
cover: z.union([image(), z.string().url()]).optional(),
featured: z.boolean().optional().default(false),
draft: z.boolean().optional().default(false),
}),
});
const tools = defineCollection({
loader: glob({ pattern: '**/index.{md,mdx}', base: './src/content/tools' }),
schema: ({ image }) =>
z.object({
name: z.string(),
summary: z.string(),
tag: z.enum(['Live', 'Beta', 'Experimental', 'Soon']),
icon: z.string().optional(),
thumbnail: z.union([image(), z.string().url()]).optional(),
authors: z.array(reference('authors')).optional(),
topics: z.array(z.string()).optional(),
tags: z.array(z.string()).optional(),
repo: z.string().url().optional(),
core: z.boolean().optional().default(false),
featured: z.boolean().optional().default(false),
draft: z.boolean().optional().default(false),
}),
});
export const collections = { posts, authors, tools };