-
Notifications
You must be signed in to change notification settings - Fork 0
/
content-collections.ts
53 lines (46 loc) · 1.07 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
49
50
51
52
53
import { defineCollection, defineConfig } from "@content-collections/core";
import { compileMDX } from "@content-collections/mdx";
import rehypeShiki from "@shikijs/rehype";
type Serializable = {
[key: string]: string;
};
const transformWithMDX = async (
doc: any,
context: any,
): Promise<Serializable> => {
const mdx = await compileMDX(context, doc, {
rehypePlugins: [
[
rehypeShiki,
{
themes: {
light: "vitesse-light",
dark: "vitesse-dark",
},
},
],
],
});
return {
...doc,
slug: doc._meta.path,
mdx,
};
};
const baseSchema = (zod: any) => ({
title: zod.string(),
description: zod.string(),
});
const createCollection = (name: string, directory: string) =>
defineCollection({
name,
directory,
include: "**/*.mdx",
schema: baseSchema,
transform: transformWithMDX,
});
const Page = createCollection("Page", "contents/page");
const Blog = createCollection("Blog", "contents/blog");
export default defineConfig({
collections: [Page, Blog],
});