-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent-collections.ts
46 lines (43 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
46
import { defineCollection, defineConfig } from '@content-collections/core';
import { compileMDX } from '@content-collections/mdx';
const posts = defineCollection({
name: 'posts',
directory: 'src/posts',
include: '**/*.mdx',
schema: (z) => ({
title: z.string(),
summary: z.string(),
date: z.string(),
}),
transform: async (document, context) => {
const mdx = await compileMDX(context, document);
const htmlDate = new Date(document.date);
return {
...document,
mdx,
htmlDate,
};
},
});
const projects = defineCollection({
name: 'projects',
directory: 'src/projects',
include: '**/*.mdx',
schema: (z) => ({
title: z.string(),
summary: z.string(),
date: z.string(),
}),
transform: async (document, context) => {
const mdx = await compileMDX(context, document);
const htmlDate = new Date(document.date);
return {
...document,
mdx,
htmlDate,
};
},
});
export default defineConfig({
collections: [posts, projects],
});