{"id":35899888,"url":"https://github.com/contentstack/gatsby-source-contentstack","last_synced_at":"2026-01-17T07:04:26.857Z","repository":{"id":39800222,"uuid":"134874563","full_name":"contentstack/gatsby-source-contentstack","owner":"contentstack","description":"Contentstack provides a source plugin for pulling content into Gatsby from Contentstack stacks. It helps you query content types and entries in Gatsby using GraphQL","archived":false,"fork":false,"pushed_at":"2026-01-16T10:59:22.000Z","size":2773,"stargazers_count":14,"open_issues_count":13,"forks_count":35,"subscribers_count":12,"default_branch":"master","last_synced_at":"2026-01-17T00:42:31.997Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/contentstack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-05-25T15:33:24.000Z","updated_at":"2025-12-20T13:51:33.000Z","dependencies_parsed_at":"2023-12-21T09:53:13.398Z","dependency_job_id":"b02b753f-dfc4-4269-9bf9-93188ef61ae2","html_url":"https://github.com/contentstack/gatsby-source-contentstack","commit_stats":{"total_commits":297,"total_committers":28,"mean_commits":"10.607142857142858","dds":0.6632996632996633,"last_synced_commit":"05d785b71a87e2365680a548b81ab7cd75fa76c0"},"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"purl":"pkg:github/contentstack/gatsby-source-contentstack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fgatsby-source-contentstack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fgatsby-source-contentstack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fgatsby-source-contentstack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fgatsby-source-contentstack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/contentstack","download_url":"https://codeload.github.com/contentstack/gatsby-source-contentstack/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fgatsby-source-contentstack/sbom","scorecard":{"id":303473,"data":{"date":"2025-08-11","repo":{"name":"github.com/contentstack/gatsby-source-contentstack","commit":"8e906825899e0b79bb87e24de5f6b52c55d894f6"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.3,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: SECURITY.md:1","Info: Found linked content: SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1","Info: Found text in security policy: SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":2,"reason":"Found 5/17 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:24","Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:25","Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1","Warn: no topLevel permission defined: .github/workflows/issues-jira.yml:1","Warn: no topLevel permission defined: .github/workflows/npm-publish.yml:1","Warn: no topLevel permission defined: .github/workflows/policy-scan.yml:1","Warn: no topLevel permission defined: .github/workflows/sca-scan.yml:1","Warn: no topLevel permission defined: .github/workflows/secrets-scan.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/contentstack/gatsby-source-contentstack/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/contentstack/gatsby-source-contentstack/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:55: update your workflow using https://app.stepsecurity.io/secureworkflow/contentstack/gatsby-source-contentstack/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:68: update your workflow using https://app.stepsecurity.io/secureworkflow/contentstack/gatsby-source-contentstack/codeql-analysis.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/issues-jira.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/contentstack/gatsby-source-contentstack/issues-jira.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/issues-jira.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/contentstack/gatsby-source-contentstack/issues-jira.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/contentstack/gatsby-source-contentstack/npm-publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/contentstack/gatsby-source-contentstack/npm-publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/policy-scan.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/contentstack/gatsby-source-contentstack/policy-scan.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/policy-scan.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/contentstack/gatsby-source-contentstack/policy-scan.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/sca-scan.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/contentstack/gatsby-source-contentstack/sca-scan.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/sca-scan.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/contentstack/gatsby-source-contentstack/sca-scan.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/secrets-scan.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/contentstack/gatsby-source-contentstack/secrets-scan.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/npm-publish.yml:20","Warn: downloadThenRun not pinned by hash: .github/workflows/secrets-scan.yml:29","Info:   0 out of  10 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 third-party GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned","Info:   0 out of   1 downloadThenRun dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENCE:0","Info: FSF or OSI recognized license: MIT License: LICENCE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":10,"reason":"SAST tool detected","details":["Info: SAST configuration detected: CodeQL","Info: SAST configuration detected: Snyk","Info: all commits (18) are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"13 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-xq7p-g2vc-g82p","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-44fp-w29j-9vj5","Warn: Project is vulnerable to: GHSA-4pg4-qvpc-4q3h","Warn: Project is vulnerable to: GHSA-g5hg-p3ph-g8qg","Warn: Project is vulnerable to: GHSA-fjgf-rc76-4x9p","Warn: Project is vulnerable to: GHSA-76c9-3jph-rj3q","Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-8cj5-5rvv-wf4v","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T21:22:00.997Z","repository_id":39800222,"created_at":"2025-08-17T21:22:00.997Z","updated_at":"2025-08-17T21:22:00.997Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28503022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-09T23:05:29.925Z","updated_at":"2026-01-17T07:04:26.841Z","avatar_url":"https://github.com/contentstack.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gatsby-source-contentstack\n\nContentstack provides a source plugin for pulling content into [Gatsby][gatsby] from [Contentstack][contentstack] stacks. It helps you query content types and entries in Gatsby using GraphQL.\n\nHere’s an example site built using this source plugin: https://xenodochial-hodgkin-8a267e.netlify.com/\n\n##### **NOTE**\n\n\u003e - Use Node v18+ and React v18+ while using v5.x.x of gatsby-source-contentstack.\n\u003e - Please refer migration guide: [Migrating from v4 to v5](https://v5.gatsbyjs.com/docs/reference/release-notes/migrating-from-v4-to-v5/)\n\u003e - Added support for subsequent fetch calls when data is being published during ongoing init calls or build process.\n\n## Install\n\n`npm install --save gatsby-source-contentstack`\n\n## How to use\n\nOpen the gatsby-config.js file from the root directory of your Gatsby project and configure it with below parameters\n\n```javascript\n// In your gatsby-config.js\n\nmodule.exports = {\n  plugins: [\n    {\n      resolve: `gatsby-source-contentstack`,\n      options: {\n        api_key: `api_key`,\n        delivery_token: `delivery_token`,\n        environment: `environment`,\n      }\n    }\n  ]\n};\n// Note: access_token is replaced by delivery_token\n```\n\n## Plugin Options\n\n| Option                 | Required | Type     | Description                                                | Default | Example |\n| ---------------------- | -------- | -------- | ---------------------------------------------------------- | ------- | ------- |\n| api_key                | Required      | string   | API Key is a unique key assigned to each stack.           | N/A     | `\"api_key\"` |\n| delivery_token         | Required      | string   | Delivery Token is a read-only credential.                 | N/A     | `\"delivery_token\"` |\n| environment            | Required      | string   | Environment where you published your data.                | N/A     | `\"environment\"` |\n| branch                 | Optional       | string   | Specify branch name. Default it would fetch from \"main\".   | `main` | `\"branch name\"` |\n| cdn                    | Optional       | string   | CDN set this to point to other CDN endpoint.              |  `\"https://cdn.contentstack.io/v3\"`   | `\"https://eu-cdn.contentstack.com/v3\"` |\n| expediteBuild          | Recommended       | boolean  | Specify true if you want to fetch/source data parallelly. | `false` |  `true` |\n| enableSchemaGeneration | Recommended       | boolean  | Specify true if you want to generate a custom schema.     | `false` | `true`  |\n| disableMandatoryFields | Optional       | boolean  | Specify true to generate optional GraphQL fields.         | `false` | `true` |\n| type_prefix            | Optional       | string   | Specify a different prefix for types.                     | `Contentstack` | `Contentstack_Stack_A` |\n| downloadImages         | Optional       | boolean  | Specify true to download all Contentstack images locally. | `false` | `true` |\n| 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. |\n| 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.|\n| 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. |\n| jsonRteToHtml          | no       | boolean  | Specify true to convert the JSON-RTE response to HTML.    | `false` | `true` |\n| httpRetries            | no       | number   | Specify the number of HTTP retries for network failures.  | `3`     | `2` |\n| limit                  | no       | number   | Specify the number of entries/assets per page (Max: 100). | `50`    | `50` |\n| 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'` |\n| 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'` |\n\n\n\nThere 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.\n\nHowever, when you want to perform `gatsby develop`, ensure to set the value of **expediteBuild** to **false**.\n\n## How to query\n\nYou can query nodes created from Contentstack using GraphQL.\n\nAll content types and the corresponding entries are pulled from your stack. They'll be created in your site's GraphQL schema under `contentstack${contentTypeID}` and `allContentstack${contentTypeID}`.\n\n**Note**: Learn to use the GraphQL tool and Ctrl+Spacebar at\n\u003chttp://localhost:8000/___graphql\u003e to discover the types and properties of your\nGraphQL model.\n\n## Querying entries\n\nIf, for example, you have `Blogs` as one of your content types, you will be able to query its entries in the following manner:\n\n```graphql\n{\n  allContentstackBlogs {\n    edges {\n      node {\n        id\n        title\n        url\n        description\n        banner {\n          filename\n          localAsset {\n            base\n            absolutePath\n            publicURL\n            url\n            childImageSharp {\n              fixed(width: 125, height: 125) {\n                base64\n              }\n            }\n          }\n        }\n        created_at\n      }\n    }\n  }\n}\n```\n\n## Query Reference fields\n\nReference fields provide references to entries of another content type(s). Since fields from\nreferred entry are often needed, the referred entry data is provided at the `reference` field.\n\n**Note**: If referenced entries are not published or deleted, then the query will not return those entries in the response.\n\n```graphql\n{\n  allContentstackBlogs {\n    edges {\n      node {\n        id\n        title\n        url\n        description\n        authors {\n          name\n        }\n        created_at\n      }\n    }\n  }\n}\n```\n\n## Querying global fields\n\nGlobal fields provide a convenient way of capturing a common set of fields. These implement\na common interface which can be used to commonise between different types using the global field.\n\nFor example, suppose you used a global field for author information:\n\n```graphql\nfragment Author on contentstack_author {\n  name\n}\n\nquery {\n  allContentstackBlogs {\n    node {\n      authors {\n        ...Author\n      }\n    }\n  }\n  allContentstackArticles {\n    node {\n      authors {\n        ...Author\n      }\n    }\n  }\n}\n```\n\n## Querying downloaded images\n\n## Prerequisites\n\nTo use this, you need to have the following plugins installed:\n\n- gatsby-transformer-sharp\n- gatsby-plugin-sharp\n- gatsby-source-filesystem\n- gatsby-plugin-image\n\n```graphql\n{\n  allContentstackAssets {\n    edges {\n      node {\n        id\n        title\n        localAsset {\n          childImageSharp {\n            fluid {\n              base64\n              aspectRatio\n              src\n              srcSet\n              sizes\n            }\n          }\n        }\n      }\n    }\n  }\n}\n```\n\nNote: By default, 20 images can be downloaded concurrently. However, if you want to download more you can set GATSBY_CONCURRENT_DOWNLOAD=100.\n\nFor ex:- GATSBY_CONCURRENT_DOWNLOAD=100 gatsby develop\n\nRemember that gatbsy-image doesn’t support GIF and SVG images.\n\nTo use GIF image, Gatsby recommends to import the image directly. In SVG, creating multiple variants of the image doesn’t make sense because it is vector-based graphics that you can freely scale without losing quality.\n\n## The new gatsby image plugin\n\nThe gatsby-image plugin lets you add responsive images to your site. By using this plugin, you can format and produce images of various qualities and sizes.\n\n## Prerequisites\n\nTo use this, you need to have the following plugins installed:\n\n- gatsby-plugin-image\n- gatsby-plugin-sharp\n- gatsby-transformer-sharp\n\n# Description\n\nNext step is to add an image to your page query and use the gatsbyImageData resolver to pass arguments that will configure your image.\n\nThe gatsbyImageData resolver allows you to pass arguments to format and configure your images.\nUsing the Contentstack Image delivery APIs you can perform various operations on the images by passing the necessary parameters.\n\nLets understand this with an example.\nIn the below example we have added several parameters to format the image.\n\n```graphql\n{\n  allContentstackBlog {\n    edges {\n      node {\n        title\n        image {\n          gatsbyImageData(\n            layout: CONSTRAINED\n            crop: \"100,100\"\n            trim: \"25,25,100,100\"\n            backgroundColor: \"cccccc\"\n            pad: \"25,25,25,25\"\n          )\n        }\n      }\n    }\n  }\n}\n```\n\nLets understand some parameters that we defined:\nlayout: This defines the layout of the image, it can be CONSTRAINED, FIXED or FULL_WIDTH.\nThe crop, trim, backgroundColor and pad parameters configure the image according to the values inserted by the user.\n\nNote: To learn more about these parameters and other available options, read our detailed documentation on [Contentstack Image delivery APIs](https://www.contentstack.com/docs/developers/apis/image-delivery-api/).\n\nThis query below returns the URL for a 20px-wide image, to use as a blurred placeholder.\nThe image is downloaded and converted to a base64-encoded data URI.\n\nHere’s an example of the same:\n\n```graphql\n{\n  allContentstackBlog {\n    edges {\n      node {\n        title\n        image {\n          gatsbyImageData(\n            layout: CONSTRAINED\n            placeholder: BLURRED\n            crop: \"100,100\"\n            trim: \"25,25,100,100\"\n            backgroundColor: \"cccccc\"\n            pad: \"25,25,25,25\"\n          )\n        }\n      }\n    }\n  }\n}\n```\n\n## Using live preview\n\nSince version 5.1, a class - `ContentstackGatsby` is provided which facilitates the setup of live preview.\n\nInitialize `ContentstackGatsby` and live preview SDK.\n\n```jsx\nimport { ContentstackGatsby } from 'gatsby-source-contentstack/live-preview';\nimport ContentstackLivePreview from '@contentstack/live-preview-utils';\n\nexport const getCSData = new ContentstackGatsby({\n  api_key: GATSBY_CONTENTSTACK_API_KEY,\n  environment: GATSBY_CONTENTSTACK_ENVIRONMENT,\n  live_preview: {\n    management_token: GATSBY_CONTENTSTACK_MANAGEMENT_TOKEN,\n    enable: true,\n    host: 'api.contentstack.io', // \"eu-api.contentstack.com\" for EU region\n  },\n});\n\nContentstackLivePreview.init({\n  stackSdk: getCSData.stackSdk,\n});\n```\n\nNext, in a page/component, pass a function to `ContentstackLivePreview`'s `onEntryChange()` or `onLiveEdit()` method. This function should call ContentstackGatsby.get() with the initial data as a parameter.\n\n```jsx\nconst Home = props =\u003e {\n  const [data, setData] = useState(props.data.allContentstackPage.nodes[0]);\n\n  const fetchLivePreviewData = async () =\u003e {\n    const updatedData = await getCSData.get(\n      props.data.allContentstackPage.nodes[0]\n    );\n    setData(updatedData);\n  };\n\n  useEffect(() =\u003e {\n    ContentstackLivePreview.onLiveEdit(fetchLivePreviewData);\n  }, []);\n\n  return \u003cdiv\u003e{data.title}\u003c/div\u003e;\n};\n```\n\nFor more information on using live preview, please refer to [Set up Live Preview](https://www.contentstack.com/docs/developers/sample-apps/build-a-starter-website-with-gatsby-and-contentstack#set-up-live-preview-optional) for Gatsby sites.\n\nFor more information checkout gatsby's image plugin documentation on usage of the [new image plugin](https://www.gatsbyjs.com/docs/how-to/plugins-and-themes/adding-gatsby-image-support/).\n\nFor more information on region support please refer [About Region's](https://www.contentstack.com/docs/developers/contentstack-regions/api-endpoints/)\n\n[gatsby]: https://www.gatsbyjs.org/\n[contentstack]: https://www.contentstack.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontentstack%2Fgatsby-source-contentstack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontentstack%2Fgatsby-source-contentstack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontentstack%2Fgatsby-source-contentstack/lists"}