-
Notifications
You must be signed in to change notification settings - Fork 0
/
sourcebit.js
82 lines (80 loc) · 2.22 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
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
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", "advanced"),
},
{
path: "/{__metadata.urlPath}",
predicate: _.matchesProperty("__metadata.modelName", "blog"),
},
{
path: "/{__metadata.urlPath}",
predicate: _.matchesProperty("__metadata.modelName", "portfolio"),
},
{
path: "/{__metadata.urlPath}",
predicate: _.matchesProperty("__metadata.modelName", "page"),
},
{
path: "/{__metadata.urlPath}",
predicate: _.matchesProperty("__metadata.modelName", "post"),
},
{
path: "/{__metadata.urlPath}",
predicate: _.matchesProperty("__metadata.modelName", "project"),
},
],
commonProps: {
pages: {
predicate: _.matchesProperty("__metadata.modelType", "page"),
},
posts: {
predicate: _.matchesProperty("__metadata.modelName", "post"),
},
projects: {
predicate: _.matchesProperty("__metadata.modelName", "project"),
},
data: {
single: true,
predicate: _.matchesProperty(
"__metadata.id",
"sourcebit-source-filesystem:data"
),
},
},
},
},
],
};