-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontentlayer.config.ts
More file actions
43 lines (41 loc) · 1.17 KB
/
contentlayer.config.ts
File metadata and controls
43 lines (41 loc) · 1.17 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
import { defineDocumentType, makeSource } from "contentlayer/source-files";
import rehypePrettyCode from "rehype-pretty-code";
import rehypeSlug from "rehype-slug";
const Blog = defineDocumentType(() => ({
name: "Blog",
filePathPattern: `blog/**/*.mdx`,
contentType: "mdx",
fields: {
title: { type: "string", required: true },
date: { type: "date", required: true },
description: { type: "string", required: false },
tags: { type: "list", of: { type: "string" }, required: false },
},
computedFields: {
slug: {
type: "string",
resolve: (doc) => {
// blog/ 폴더를 제외하고 나머지 경로를 slug로 사용
const relativePath = doc._raw.sourceFilePath.replace(/^.*?blog\//, "");
// 파일 확장자 제거하고 소문자로 변환
return relativePath.replace(/\.mdx$/, "").toLowerCase();
},
},
},
}));
export default makeSource({
contentDirPath: "src/content",
documentTypes: [Blog],
mdx: {
rehypePlugins: [
[
// @ts-expect-error vfile 타입 충돌 무시
rehypePrettyCode,
{
theme: "dracula",
},
],
rehypeSlug,
],
},
});