forked from piotrkulpinski/openalternative
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent-collections.ts
36 lines (31 loc) · 927 Bytes
/
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
import { defineCollection, defineConfig } from "@content-collections/core"
import { type Options, compileMDX } from "@content-collections/mdx"
import rehypeAutolinkHeadings from "rehype-autolink-headings"
import rehypeSlug from "rehype-slug"
const mdxOptions: Options = {
rehypePlugins: [rehypeSlug, rehypeAutolinkHeadings],
}
const posts = defineCollection({
name: "posts",
directory: "content/posts",
include: "**/*.md",
schema: z => ({
title: z.string(),
description: z.string(),
image: z.string().optional(),
publishedAt: z.string(),
updatedAt: z.string().optional(),
author: z.object({
name: z.string(),
image: z.string(),
twitterHandle: z.string(),
}),
}),
transform: async (data, context) => {
const content = await compileMDX(context, data, mdxOptions)
return { ...data, content }
},
})
export default defineConfig({
collections: [posts],
})