-
Notifications
You must be signed in to change notification settings - Fork 0
/
sourcebit.js
47 lines (44 loc) · 2.36 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
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 || 'luigc8x707f6',
// 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', 'advanced') },
{ path: '/{stackbit_url_path}', predicate: _.matchesProperty('__metadata.modelName', 'blog') },
{ path: '/{stackbit_url_path}', predicate: _.matchesProperty('__metadata.modelName', 'portfolio') },
{ 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', 'project') }
],
commonProps: (items) => {
return {
pages: _.filter(items, item => ["advanced","blog","portfolio","page","post","project"].includes(_.get(item, '__metadata.modelName'))),
data: {
config: _.find(items, _.matchesProperty('__metadata.modelName', 'config'))
}
};
}
}
}
]
};