-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent-collections.ts
44 lines (41 loc) · 1.03 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
import { defineCollection, defineConfig } from '@content-collections/core';
import { compileMDX } from '@content-collections/mdx';
import { remarkCodeHike } from 'codehike/mdx';
import remarkGfm from 'remark-gfm';
import rehypePrettyCode from 'rehype-pretty-code';
const posts = defineCollection({
name: 'posts',
directory: 'contents',
include: '*.mdx',
schema: (z) => ({
title: z.string(),
date: z.string(),
tags: z.array(z.string()),
pinned: z.boolean(),
}),
transform: async (document, context) => {
const mdx = await compileMDX(context, document, {
rehypePlugins: [
[
rehypePrettyCode,
{
// TODO: 테마에 맞게 수정
theme: 'slack-dark',
keepBackground: true,
},
],
],
remarkPlugins: [
remarkGfm,
[remarkCodeHike, { showCopyButton: true, autoImport: true }],
],
});
return {
...document,
mdx,
};
},
});
export default defineConfig({
collections: [posts],
});