forked from loki315zx/avif.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contentlayer.config.js
116 lines (109 loc) · 2.34 KB
/
contentlayer.config.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { defineDocumentType, makeSource } from "contentlayer/source-files";
import rehypePresetMinify from "rehype-preset-minify";
const abstractDocumentFrontMatter = {
title: {
type: "string",
required: true,
},
description: {
type: "string",
required: true,
},
keyword: {
type: "string",
},
datePublished: {
type: "date",
},
dateModified: {
type: "date",
},
sources: {
type: "json",
},
tags: {
type: "json",
},
questions: {
type: "json",
},
};
const commonComputedFields = {
url: {
type: "string",
resolve: (doc) => "blog/" + doc._raw.flattenedPath,
},
slug: {
type: "string",
resolve: (doc) => doc._raw.sourceFileName.replace(/\.mdx$/, ""),
},
category: {
type: "string",
resolve: (doc) => doc._raw.flattenedPath.split("/").shift(),
},
};
export const Articles = defineDocumentType(() => ({
name: "Articles",
filePathPattern: `articles/*.mdx`,
contentType: "mdx",
fields: { ...abstractDocumentFrontMatter },
computedFields: { ...commonComputedFields },
}));
export const Comparisons = defineDocumentType(() => ({
name: "Comparisons",
filePathPattern: `comparisons/*.mdx`,
contentType: "mdx",
fields: { ...abstractDocumentFrontMatter },
computedFields: { ...commonComputedFields },
}));
export const FAQs = defineDocumentType(() => ({
name: "FAQs",
filePathPattern: `faq/*.mdx`,
contentType: "mdx",
fields: {
title: {
type: "string",
required: true,
},
answer: {
type: "string",
required: true,
},
description: {
type: "string",
required: true,
},
datePublished: {
type: "date",
},
dateModified: {
type: "date",
},
},
computedFields: { ...commonComputedFields },
}));
export const Tutorials = defineDocumentType(() => ({
name: "Tutorials",
filePathPattern: `tutorials/*.mdx`,
contentType: "mdx",
fields: {
...abstractDocumentFrontMatter,
subcategory: {
type: "string",
required: true,
},
support: {
type: "enum",
options: ["full", "partial", "no"],
required: true,
},
},
computedFields: { ...commonComputedFields },
}));
export default makeSource({
contentDirPath: "blog",
documentTypes: [Articles, Comparisons, FAQs, Tutorials],
mdx: {
rehypePlugins: [rehypePresetMinify],
},
});