This repository was archived by the owner on Aug 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathcontentlayer.config.js
68 lines (62 loc) · 1.51 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
import { defineDocumentType, makeSource } from "contentlayer/source-files";
const StaticPage = defineDocumentType(() => ({
name: "StaticPage",
filePathPattern: `static/**/*.md`,
fields: {
title: {
type: "string",
description: "The title of the static page",
required: true,
},
date: {
type: "date",
description: "The date of the static page",
required: true,
},
},
computedFields: {
url: {
type: "string",
resolve: (staticPage) => {
// const [, filename, _fileext] = /static\/(.*)\.(\w+)$/.exec(
const [, filename] = /static\/(.*)$/.exec(
staticPage._raw.flattenedPath,
);
return `/${filename}`;
},
},
},
}));
const Story = defineDocumentType(() => ({
name: "Story",
filePathPattern: `stories/**/*.md`,
fields: {
title: {
type: "string",
description: "The title of the story",
required: true,
},
date: {
type: "date",
description: "The date of the story",
required: true,
},
},
computedFields: {
url: {
type: "string",
resolve: (story) => {
// const [, filename, _fileext] = /stories\/(.*)\.(\w+)$/.exec(
const [, filename] = /stories\/(.*)$/.exec(
story._raw.flattenedPath,
);
return `/stories/${filename}`;
},
},
},
}));
const source = makeSource({
contentDirPath: "content",
documentTypes: [StaticPage, Story],
});
export { source, source as default, StaticPage, Story };