-
Notifications
You must be signed in to change notification settings - Fork 0
/
sourcebit.js
53 lines (49 loc) · 2.06 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
50
51
52
53
const _ = require('lodash');
const isDev = process.env.NODE_ENV === 'development';
module.exports = {
plugins: [
{
module: require('sourcebit-source-filesystem'),
options: {
watch: isDev
}
},
// flatten all frontmatter and markdown data
({ data }) => {
const objects = data.objects.map(object => {
if (_.has(object, 'frontmatter')) {
return {
__metadata: object.__metadata,
...object.frontmatter,
markdown_content: object.markdown || null
}
}
return object;
});
return {
...data,
objects
};
},
{
module: require('sourcebit-target-next'),
options: {
liveUpdate: isDev,
flattenAssetUrls: true,
pages: [
{ path: '/{__metadata.urlPath}', predicate: _.matchesProperty('__metadata.modelName', 'docs') },
{ path: '/{__metadata.urlPath}', predicate: _.matchesProperty('__metadata.modelName', 'advanced') },
{ path: '/{__metadata.urlPath}', predicate: _.matchesProperty('__metadata.modelName', 'blog') },
{ path: '/{__metadata.urlPath}', predicate: _.matchesProperty('__metadata.modelName', 'page') },
{ path: '/{__metadata.urlPath}', predicate: _.matchesProperty('__metadata.modelName', 'post') }
],
commonProps: {
pages: { predicate: _.matchesProperty('__metadata.modelType', 'page') },
posts: { predicate: _.matchesProperty('__metadata.modelName', 'post') },
docs: { predicate: _.matchesProperty('__metadata.modelName', 'docs') },
data: { single: true, predicate: _.matchesProperty('__metadata.id', 'sourcebit-source-filesystem:data') }
}
}
}
]
};