-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent-collections.ts
More file actions
48 lines (45 loc) · 1.11 KB
/
Copy pathcontent-collections.ts
File metadata and controls
48 lines (45 loc) · 1.11 KB
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';
import { z } from 'zod';
const posts = defineCollection({
name: 'Post',
directory: 'content/posts',
include: '**/*.mdx',
schema: z.object({
title: z.string(),
description: z.string(),
date: z.string(),
published: z.boolean().optional().default(true),
tags: z.array(z.string()).optional().default([]),
}),
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: '**/*.mdx',
schema: z.object({
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],
});