-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.config.ts
43 lines (37 loc) · 1.26 KB
/
content.config.ts
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
import { defineCollection, reference, z } from 'astro:content';
import { glob, file } from 'astro/loaders';
const resources = defineCollection({
loader: glob({ pattern: "**/*.md", base: "./src/content/resources" }),
schema: z.object({
name: z.string(),
featured: z.boolean().default(false),
short: z.string(),
description: z.string(),
lang: z.array(z.enum(["Python", "R", "Java", "JavaScript"])),
home: z.string().url(),
issues: z.string().url(),
docs: z.string().url(),
logo: z.string(),
tags: z.array(reference("tag"))
})
});
// export const tagSchema = z
// .object({
// id: z.string(),
// slug: z.string().optional(),
// }).superRefine((data, ctx) => {
// if (!data.slug) {
// data.slug = data.id.toLowerCase().replace(/\s+/g, "-");
// }
// });
// export const tagSchema = z.object({
// id: z.string(),
// slug: z.string().default("").transform((slug, ctx) =>
// slug || ctx.originalInput.id.toLowerCase().replace(/\s+/g, "-")
// ),
// });
// export const tags = defineCollection({
// loader: file("src/content/tags/tags.json"),
// schema: tagSchema,
// });
export const collections = { resources };