-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsourcebit.js
45 lines (42 loc) · 2.08 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
const _ = require('lodash');
const isDev = process.env.NODE_ENV === 'development';
module.exports = {
plugins: [
{
module: require('sourcebit-source-contentful'),
options: {
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
// deliveryToken is optional, if not specified will be automatically created and reused
deliveryToken: process.env.CONTENTFUL_DELIVERY_TOKEN,
// previewToken is optional, if not specified will be automatically created and reused
previewToken: process.env.CONTENTFUL_PREVIEW_TOKEN,
spaceId: process.env.CONTENTFUL_SPACE_ID || 'sr6nacuav1bg',
// Which content environment to use, when Stackbit sets a split tests on Netlify, it use the BRANCH variable to identify the bucket
environment: process.env.BRANCH || process.env.CONTENTFUL_ENVIRONMENT || 'master',
preview: isDev,
watch: isDev
}
},
{
module: require('sourcebit-target-next'),
options: {
liveUpdate: isDev,
flattenAssetUrls: true,
pages: [
{ path: '/{stackbit_url_path}', predicate: _.matchesProperty('__metadata.modelName', 'page') },
{ path: '/{stackbit_url_path}', predicate: _.matchesProperty('__metadata.modelName', 'post') },
{ path: '/{stackbit_url_path}', predicate: _.matchesProperty('__metadata.modelName', 'advanced') }
],
commonProps: (items) => {
return {
pages: _.filter(items, item => ['page', 'post', 'advanced'].includes(_.get(item, '__metadata.modelName'))),
posts: _.filter(items, item => _.get(item, '__metadata.modelName') === 'post'),
data: {
config: _.find(items, _.matchesProperty('__metadata.modelName', 'config'))
}
};
}
}
}
]
};