-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent-collections.ts
45 lines (42 loc) · 1.01 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
import { defineCollection, defineConfig } from "@content-collections/core";
import { compileMDX } from "@content-collections/mdx";
const posts = defineCollection({
name: "Post",
directory: "content/posts",
include: "**/*.mdx",
schema: (z) => ({
title: z.string(),
description: z.string(),
date: z.string(),
}),
transform: async (document, context) => {
const body = await compileMDX(context, document);
const slug = document._meta.path;
return {
...document,
slug,
body,
};
},
});
const pages = defineCollection({
name: "pages",
directory: "content/pages",
include: "**/*.md(x)?",
schema: (z) => ({
title: z.string(),
description: z.string(),
}),
transform: async (document, context) => {
const body = await compileMDX(context, document);
const slug = document._meta.path;
return {
...document,
body,
slug,
};
},
});
export default defineConfig({
collections: [posts, pages],
});