-
Notifications
You must be signed in to change notification settings - Fork 49
/
content-collections.ts
49 lines (46 loc) · 1.12 KB
/
content-collections.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
44
45
46
47
48
49
import { defineCollection, defineConfig } from "@content-collections/core";
import { compileMDX } from "@content-collections/mdx";
const posts = defineCollection({
name: "posts",
directory: "./data/post",
include: "*.mdx",
schema: (z) => ({
date: z.string(),
title: z.string(),
subtitle: z.string().optional(),
tweetUrl: z.string().optional(),
draft: z.boolean().optional(),
}),
transform: async (document, context) => {
const mdx = await compileMDX(context, document);
return {
...document,
mdx,
};
},
});
const tools = defineCollection({
name: "tools",
directory: "./data/tool",
include: "*.mdx",
schema: (z) => ({
brand: z.string(),
name: z.string(),
definition: z.string(),
favorite: z.boolean(),
category: z.string(),
images: z.string().optional(),
order: z.number().optional(),
draft: z.boolean().optional(),
}),
transform: async (document, context) => {
const mdx = await compileMDX(context, document);
return {
...document,
mdx,
};
},
});
export default defineConfig({
collections: [posts, tools],
});