diff --git a/README.md b/README.md index edfc99a..d7ce59b 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ module.exports = { addDataTo: locals, accessToken: 'xxx', spaceId: 'xxx', + environment: 'xxx', contentTypes: [ { name: 'posts', @@ -236,6 +237,22 @@ new Contentful({ }) ``` +### Multiple Environments + +Using [Contentful's Environments](https://www.contentful.com/developers/docs/concepts/multiple-environments), you can specify different branches in a single space for staging and other environments: + +```js +new Contentful({ + addDataTo: locals, + accessToken: 'xxx', + preview: false; + spaceId: 'xxx', + environment: 'staging' // Or whatever your environment is called +}) +``` + +By default `environment` is set to `master`, which is provided with every Contentful space. For each environment you want to use, specify the name as it's provided in Contentful. + ### JSON Output Finally, if you'd like to have the output written locally to a JSON file so that it's cached locally, you can pass the name of the file, resolved relative to your project's output, as a `json` option to the plugin. For example: diff --git a/lib/index.js b/lib/index.js index 418ca2e..e7c72d3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -20,7 +20,8 @@ class Contentful { this.client = contentful.createClient({ accessToken: this.accessToken, space: this.spaceId, - host: this.preview ? 'preview.contentful.com' : '' + host: this.preview ? 'preview.contentful.com' : '', + environment: this.environment || 'master' }) bindAllClass(this, ['apply', 'run']) }