Skip to content

Commit f4f238a

Browse files
Merge pull request #245 from contentstack/staging
Staging->main
2 parents fba7069 + 3719828 commit f4f238a

File tree

4 files changed

+58
-85
lines changed

4 files changed

+58
-85
lines changed

README.md

Lines changed: 36 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -20,72 +20,46 @@ Open the gatsby-config.js file from the root directory of your Gatsby project an
2020

2121
```javascript
2222
// In your gatsby-config.js
23-
plugins: [
24-
{
25-
resolve: `gatsby-source-contentstack`,
26-
options: {
27-
// Required: API Key is a unique key assigned to each stack.
28-
api_key: `api_key`,
2923

30-
// Required: Delivery Token is a read-only credential.
31-
delivery_token: `delivery_token`,
32-
33-
// Required: Environment where you published your data.
34-
environment: `environment`,
35-
36-
// Optional: Specify branch name. Default it would fetch from "main".
37-
branch: `branch name`,
38-
39-
// Optional: CDN set this to point to other cdn end point. For eg: https://eu-cdn.contentstack.com/v3
40-
cdn: `cdn_url`,
41-
42-
// Recommended: Specify true if you want to fetch/source data parallelly. It enhances the performance on both gatsby build/develop command.
43-
expediteBuild: `boolean_value`,
44-
45-
// Recommended: Specify true if you want to generate custom schema when the content type models are complex.
46-
enableSchemaGeneration : `boolean_value`,
47-
48-
// Optional: Specify true if you want to generate optional graphql fields for mandatory Contentstack fields
49-
disableMandatoryFields : `boolean_value`,
50-
51-
// Optional: Specify a different prefix for types. This is useful in cases where you have multiple instances of the plugin to be connected to different stacks.
52-
type_prefix: `Contentstack`, // (default)
53-
54-
// Optional: Specify true if you want to download all your contentstack images locally
55-
downloadImages: `boolean_value`,
56-
57-
// Optional: Specify the content types from which you want the plugin to retrieve data.
58-
contentTypes: [‘blog’,’author’],
59-
// This will fetch the data of the ‘blog’ and ‘author’ content types only.
60-
61-
// Optional: Specify the content types that the plugin should exclude while fetching data of all content types.
62-
excludeContentTypes: [‘home’,’about’],
63-
// This will fetch the data of all the available content types excluding the ‘home’ and ‘about’ content types.
64-
65-
// Optional: Include the locales that you want the plugin to fetch data from.
66-
locales: [‘en-us’,’fr-fr’],
67-
// In this case, the plugin will fetch only English (United States) and French (France) language data.
68-
69-
// Optional: Specify true to convert the JSON-RTE repsonse to HTML. Default it is set to false
70-
jsonRteToHtml: false ,
71-
72-
// Optional: Specify a number to perform http-retries for network failures. By default it is set to 3.
73-
httpRetries: 2,
74-
75-
//Optional: Specify the number of entries/assets to be fetched per page. Maximum limit accepted is 100. By default it is set to 50.
76-
limit: 50
24+
module.exports = {
25+
plugins: [
26+
{
27+
resolve: `gatsby-source-contentstack`,
28+
options: {
29+
api_key: `api_key`,
30+
delivery_token: `delivery_token`,
31+
environment: `environment`,
32+
}
33+
}
34+
]
35+
};
36+
// Note: access_token is replaced by delivery_token
37+
```
7738

78-
//Optional: Specify the header to be passed to Contentstack API
79-
enableEarlyAccessKey: 'x-header-ea'
39+
## Plugin Options
40+
41+
| Option | Required | Type | Description | Default | Example |
42+
| ---------------------- | -------- | -------- | ---------------------------------------------------------- | ------- | ------- |
43+
| api_key | Required | string | API Key is a unique key assigned to each stack. | N/A | `"api_key"` |
44+
| delivery_token | Required | string | Delivery Token is a read-only credential. | N/A | `"delivery_token"` |
45+
| environment | Required | string | Environment where you published your data. | N/A | `"environment"` |
46+
| branch | Optional | string | Specify branch name. Default it would fetch from "main". | `main` | `"branch name"` |
47+
| cdn | Optional | string | CDN set this to point to other CDN endpoint. | `"https://cdn.contentstack.io/v3"` | `"https://eu-cdn.contentstack.com/v3"` |
48+
| expediteBuild | Recommended | boolean | Specify true if you want to fetch/source data parallelly. | `false` | `true` |
49+
| enableSchemaGeneration | Recommended | boolean | Specify true if you want to generate a custom schema. | `false` | `true` |
50+
| disableMandatoryFields | Optional | boolean | Specify true to generate optional GraphQL fields. | `false` | `true` |
51+
| type_prefix | Optional | string | Specify a different prefix for types. | `Contentstack` | `Contentstack_Stack_A` |
52+
| downloadImages | Optional | boolean | Specify true to download all Contentstack images locally. | `false` | `true` |
53+
| contentTypes | Optional | string[] | Specify the content types to retrieve data from. | | `[‘blog’,’author’]` This will fetch the data of the ‘blog’ and ‘author’ content types only. |
54+
| excludeContentTypes | Optional | string[] | Specify the content types to exclude while fetching data. | | `[‘home’,’about’]` This will fetch the data of all the available content types excluding the ‘home’ and ‘about’ content types.|
55+
| locales | no | string[] | Include the locales that you want to fetch data from. | | `[‘en-us’,’fr-fr’]` In this case, the plugin will fetch only English (United States) and French (France) language data. |
56+
| jsonRteToHtml | no | boolean | Specify true to convert the JSON-RTE response to HTML. | `false` | `true` |
57+
| httpRetries | no | number | Specify the number of HTTP retries for network failures. | `3` | `2` |
58+
| limit | no | number | Specify the number of entries/assets per page (Max: 100). | `50` | `50` |
59+
| enableEarlyAccessKey | no | string | Specify list of headers to be passed to Contentstack API for the key specified in enableEarlyAccessKey. The Value should be a string. In case of multiple headers, separate them with a comma. | | `'x-header-ea'` |
60+
| enableEarlyAccessValue | no | string | Specify list of headers to be passed to Contentstack API for the key specified in enableEarlyAccessKey. The Value should be a string. In case of multiple headers, separate them with a comma: 'header1,header2' | | `'newcda,taxonomy'` |
8061

81-
//Optional: Specify list of headers to be passed to Contentstack API for the key specified in enableEarlyAccessKey. The Value should be a string. In case of multiple headers, separate them with a comma. For eg:'header1,header2'
82-
enableEarlyAccessValue: 'newcda,taxonomy'
8362

84-
},
85-
},
86-
]
87-
// Note: access_token is replaced by delivery_token
88-
```
8963

9064
There is a provision to speed up the `gatsby build` process. To do this, you can set the value of the **expediteBuild** to **true**. So when you set the value of this parameter to true, the build process is significantly enhanced as only published assets and entries are synced parallelly.
9165

package-lock.json

Lines changed: 21 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gatsby-source-contentstack",
3-
"version": "5.3.5",
3+
"version": "5.4.0",
44
"description": "Gatsby source plugin for building websites using Contentstack as a data source",
55
"scripts": {
66
"prepublish": "npm run build",

src/fetch.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,6 @@ const getData = async (url, options) => {
144144
}
145145
reject(data);
146146
} else {
147-
if (data.items) {
148-
const filteredData = data?.items.filter(item => {
149-
return item.data.hasOwnProperty('publish_details');
150-
});
151-
data.items = filteredData;
152-
}
153147
resolve(data);
154148
}
155149
})

0 commit comments

Comments
 (0)