-
Notifications
You must be signed in to change notification settings - Fork 0
/
contented.config.js
66 lines (66 loc) · 1.58 KB
/
contented.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
/** @type {import('@birthdayresearch/contented').ContentedConfig} */
module.exports = {
preview: {
name: 'Valkyr',
url: 'https://docs.kodemon.net',
github: {
url: 'https://github.com/kodemon/valkyr',
},
},
processor: {
rootDir: '../',
pipelines: [
{
type: 'Docs',
pattern: ['./README.md', './docs/**/*.md'],
processor: 'md',
fields: {
title: {
type: 'string',
},
},
transform: (file) => {
if (file.path === '/readme') {
file.fields.title = 'Valkyr';
file.path = '/';
file.sections = [];
} else {
file.path = file.path.replaceAll(/^\/docs\/?/g, '/');
file.sections = file.sections.slice(1);
}
return file;
},
sort: (a) => {
return a.path === '/' ? -1 : 0;
},
},
{
type: 'Packages',
pattern: 'packages/**/*.md',
processor: 'md',
fields: {
title: {
type: 'string',
},
sections: {
type: 'string[]',
},
},
transform: (file) => {
file.path = file.path.replaceAll(/\/readme$/g, '');
file.sections = file.fields.sections;
return file;
},
sort: (a, b) => {
if (a.sections.length === 0) {
return -1;
}
if (b.sections.length === 0) {
return 1;
}
return a.sections[0].localeCompare(b.sections[0]);
}
}
]
}
};