-
Notifications
You must be signed in to change notification settings - Fork 348
Expand file tree
/
Copy pathcontent-collections.ts
More file actions
34 lines (31 loc) · 936 Bytes
/
content-collections.ts
File metadata and controls
34 lines (31 loc) · 936 Bytes
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
import { defineCollection, defineConfig } from "@content-collections/core";
import { compileMDX } from "@content-collections/mdx";
import remarkGfm from "remark-gfm";
import { z } from "zod";
import { remarkCodeMeta } from "./src/lib/remark-code-meta";
const posts = defineCollection({
name: "posts",
directory: "content",
include: "**/*.mdx",
schema: z.object({
title: z.string(),
publishedAt: z.string(),
updatedAt: z.string().optional(),
author: z.string().optional(),
summary: z.string(),
image: z.string().optional(),
content: z.string(),
}),
transform: async (document, context) => {
const mdx = await compileMDX(context, document, {
remarkPlugins: [remarkGfm, remarkCodeMeta],
});
return {
...document,
mdx,
};
},
});
export default defineConfig({
collections: [posts],
});