/
gatsby-config.js
33 lines (28 loc) · 849 Bytes
/
gatsby-config.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
let contentfulConfig
try {
// Load the Contentful config from the .contentful.json
contentfulConfig = require('./.contentful')
} catch (_) {}
// Overwrite the Contentful config with environment variables if they exist
contentfulConfig = {
spaceId: process.env.CONTENTFUL_SPACE_ID || contentfulConfig.spaceId,
accessToken: process.env.CONTENTFUL_DELIVERY_TOKEN || contentfulConfig.accessToken,
}
const { spaceId, accessToken } = contentfulConfig
if (!spaceId || !accessToken) {
throw new Error(
'Contentful spaceId and the delivery token need to be provided.'
)
}
module.exports = {
pathPrefix: '/gatsby-contentful-starter',
plugins: [
'gatsby-transformer-remark',
'gatsby-plugin-react-helmet',
'gatsby-plugin-sharp',
{
resolve: 'gatsby-source-contentful',
options: contentfulConfig,
}
],
}