@berlitz/gatsby-source-contentstack

中文文档
9.11.5发布于 2026/05/28MITCommonJS近 30 天下载 2147

Gatsby source plugin for building websites using Contentstack as a data source

原始使用文档
文档目录6 节
  1. Install
  2. How to use
  3. How to query
  4. Querying entries
  5. Query Reference fields
  6. Coming soon

IMPORTANT NOTICE

This is a fork of the original repository, customized for Berlitz.

gatsby-source-contentstack

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.

Here’s an example site built using this source plugin: https://xenodochial-hodgkin-8a267e.netlify.com/

Install

npm install --save gatsby-source-contentstack

How to use

Open the gatsby-config.js file from the root directory of your Gatsby project and configure it with below parameters

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-source-contentstack`,
    options: {
      // API Key is a unique key assigned to each stack. This is required.
      api_key: `api_key`,

      // Access Token is a read-only credential . This is required.
      access_token: `access_token`,

      // Environment where you published your data.
      environment: `environment`,
    },
  },
]

How to query

You can query nodes created from Contentstack using GraphQL.

All 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}.

Note: Learn to use the GraphQL tool and Ctrl+Spacebar at http://localhost:8000/___graphql to discover the types and properties of your GraphQL model.

Querying entries

If, for example, you have Blogs as one of your content types, you will be able to query its entries in the following manner:

{
  allContentstackBlogs {
    edges {
      node {
        id
        title
        url
        description
        banner {
          filename
          url
          title
        }
        created_at
      }
    }
  }
}

Query Reference fields

Reference fields provide references to entries of another content type(s). Since fields from referred entry is often needed, the referred entry data is provided at the reference field.

{
  allContentstackBlogs {
    edges {
      node {
        id
        title
        url
        description
        authors {
          name
        }
        created_at
      }
    }
  }
}

Coming soon

  • Asset type and Image processing support using gatsby-transformer-sharp, gatsby-plugin-sharp.

版本与发布记录

@berlitz/gatsby-source-contentstack 共发布 138 个版本,首次发布于 2018/12/19;过去 12 个月发布了 5 个版本。

版本发布日期距今
9.11.5latest2026/05/285 个月前
9.11.42026/05/195 个月前
9.11.32026/05/185 个月前
9.11.22026/04/246 个月前
9.11.12026/03/107 个月前
9.11.02025/03/201.6 年前

其他发布通道:canary → 8.10.2-alpha.119。

关于 @berlitz/gatsby-source-contentstack 的常见问题

@berlitz/gatsby-source-contentstack 是什么?

Gatsby source plugin for building websites using Contentstack as a data source

如何安装 @berlitz/gatsby-source-contentstack?

在项目目录运行 npm install @berlitz/gatsby-source-contentstack,或使用 pnpm add / yarn add / bun add。

@berlitz/gatsby-source-contentstack 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/berlitz__gatsby-source-contentstack 是否存在。

@berlitz/gatsby-source-contentstack 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@berlitz/gatsby-source-contentstack 可以商用吗?

@berlitz/gatsby-source-contentstack 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@berlitz/gatsby-source-contentstack 的下载量有多少?

根据 npm 官方下载统计,@berlitz/gatsby-source-contentstack 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,147 次,日均约 72 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@berlitz/gatsby-source-contentstack 还在维护吗?

最新版本 9.11.5 发布于 2026/05/28(5 个月前);至今共发布 138 个版本,其中过去 12 个月发布了 5 个;首次发布于 2018/12/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。