-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsourcebit.js
49 lines (47 loc) · 1.88 KB
/
sourcebit.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
const path = require('path');
const { cssClassesFromFilePath, urlPathFromFilePath } = require('./src/utils/path');
const { resolveReferenceFields, flattenMarkdownData, postProcessContactFormEmails } = require('./src/utils/process-data');
const isDev = process.env.NODE_ENV === 'development';
module.exports = {
plugins: [
{
module: require('sourcebit-source-filesystem'),
options: {
watch: isDev,
sources: [
{ name: 'pages', path: path.join(__dirname, 'content/pages') },
{ name: 'data', path: path.join(__dirname, 'content/data') }
]
}
},
flattenMarkdownData(),
resolveReferenceFields(),
postProcessContactFormEmails(),
{
module: require('sourcebit-target-next'),
options: {
liveUpdate: isDev,
flattenAssetUrls: true,
pages: (data) => {
const pages = data.filter((page) => page.__metadata.sourceName === 'pages');
const site = data.find((page) => page.__metadata.id === 'content/data/config.json');
return pages.map((page) => {
const path = urlPathFromFilePath(page.__metadata.relSourcePath);
const pageCssClasses = cssClassesFromFilePath(page.__metadata.relSourcePath);
return {
path,
site,
page: {
...page,
__metadata: {
...page.__metadata,
pageCssClasses
}
}
};
});
}
}
}
]
};