-
Notifications
You must be signed in to change notification settings - Fork 1
/
contentlayer.config.ts
55 lines (52 loc) · 1.63 KB
/
contentlayer.config.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
54
55
import { defineDocumentType, makeSource } from "contentlayer/source-files";
import rehypePrism from "rehype-prism-plus";
import rehypeCodeTitles from "rehype-code-titles";
const configDocumentType = (docName: string, filePath: string) => {
return defineDocumentType(() => ({
name: docName,
contentType: "mdx",
filePathPattern: `${filePath}/*.mdx`,
fields: {
title: { type: "string", required: true },
date: { type: "string", required: true },
description: { type: "string", required: true },
category: { type: "string", required: true },
},
computedFields: {
slug: {
type: "string",
resolve: (doc) => doc._raw.sourceFileName.replace(/\.mdx$/, ""),
},
},
}));
};
const Js = configDocumentType("Js", "js");
const Git = configDocumentType("Git", "git");
const Next = configDocumentType("Next", "next");
const Other = configDocumentType("Other", "other");
const React = configDocumentType("React", "react");
const Types = configDocumentType("Types", "types");
const Algorithm = configDocumentType("Algorithm", "algorithm");
const BackEnd = configDocumentType("BackEnd", "backend");
const DataBase = configDocumentType("DataBase", "db");
const Server = configDocumentType("Server", "server");
const Article = configDocumentType("Article", "article");
export default makeSource({
contentDirPath: "posts",
documentTypes: [
Js,
Git,
Next,
Other,
React,
Types,
Algorithm,
BackEnd,
DataBase,
Server,
Article,
],
mdx: {
rehypePlugins: [rehypeCodeTitles, rehypePrism],
},
});