-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent-collections.ts
48 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
46
47
48
import { defineCollection, defineConfig } from "@content-collections/core";
import { compileMDX } from "@content-collections/mdx";
const authors = defineCollection({
name: "authors",
directory: "content/authors",
include: "*.mdx",
schema: (z) => ({
ref: z.string(),
displayName: z.string(),
image: z.string(),
link: z.string(),
bio: z.string()
}),
});
const posts = defineCollection({
name: "posts",
directory: "content/posts",
include: "*.mdx",
schema: (z) => ({
title: z.string(),
summary: z.string(),
author: z.string(),
date: z.string(),
excerpt:z.string(),
image: z.string(),
tags: z.array(z.string()),
}),
transform: async (document, context) => {
const body = await compileMDX(context, document);
const author = await context
.documents(authors)
.find((a) => a.ref === document.author);
return {
...document,
body,
author,
};
},
});
export default defineConfig({
collections: [authors, posts],
});