# @berlitz/gatsby-source-contentstack 中文文档

规范地址：https://npmcn.com/package/%40berlitz/gatsby-source-contentstack/

版本：9\.11\.5
npm 元数据更新时间：2026-11-05T19:18:24.556Z
中文译文更新时间：2026-11-07T23:00:46.908Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40berlitz/gatsby-source-contentstack
原文对照：https://npmcn.com/package/%40berlitz/gatsby-source-contentstack/?lang=original
项目主页：https://github.com/berlitz-global/blitz/tree/master/gatsby-source-contentstack/CHANGELOG.md
源码仓库：https://github.com/berlitz-global/gatsby-source-contentstack

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：117 kB，20 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：7 个
- 首次发布：2018-12-19T04:29:18.507Z
- 最新版本发布：2026-05-28T15:22:37.924Z
- 近 30 天下载量：2147（2026-10-08 至 2026-11-06，npm 官方下载统计）
- 已发布版本数：138（近 12 个月 5 个）

## 中文简介

Gatsby 创建网站的源插件, 使用 Concesstack 作为数据源

## 安装

```sh
npm install @berlitz/gatsby-source-contentstack
```

也可以使用：`pnpm add @berlitz/gatsby-source-contentstack`、`yarn add @berlitz/gatsby-source-contentstack`、`bun add @berlitz/gatsby-source-contentstack`

## README

# 重要通知

这是叉子 [原始仓库](https://github.com/contentstack/gatsby-source-contentstack)为贝利茨定制的.

# gatsby 源代码存储

目录tack提供了一个源插件,用于将内容拉入 [盖茨比](https://www.gatsbyjs.org/) 从 [目录](https://www.contentstack.com/) 堆叠。 它帮助您使用 GraphQL 在 Gatsby 中查询内容类型和条目 .

以下是使用此源插件构建的示例站点: [https://xenodochial-hodgkin-8a267e.netlife.com/ (中文(简体) )](https://xenodochial-hodgkin-8a267e.netlify.com/)

## 安装

`npm install --save gatsby-source-contentstack`

## 如何使用

从您的 Gatsby 项目的根目录打开 Gatsby- config.js 文件, 并配置以下参数

```javascript
// 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`,
    },
  },
]
```

## 如何查询

您可以使用 GraphQL 查询从 Contack 创建的节点 .

所有内容类型和相应的条目都取自您的堆栈 。 将在你网站的GraphQL计划下创建 `contentstack${contentTypeID}` 财务报告和审定财务报表 `allContentstack${contentTypeID}`。 。 。 .

**说明**: 学习使用 GraphQL 工具和 Ctrl+ Spacebar [http://localhost:8000/ graphql (英语)](http://localhost:8000/___graphql) 以发现您的类型和属性 图QL模型.

### 查询条目

举例来说,如果 `Blogs` 作为您的内容类型之一,您可以以下列方式查询其条目:

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

### 查询引用字段

引用字段为其它内容类型的条目提供引用. 由于来自 引用的条目数据 `reference` 字段.

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

## 马上就来

-   使用资产类型和图像处理支持 `gatsby-transformer-sharp`, (中文(简体) ), `gatsby-plugin-sharp`。 。 。 .

## 常见问题

### @berlitz/gatsby-source-contentstack 是什么？

Gatsby 创建网站的源插件, 使用 Concesstack 作为数据源

### 如何安装 @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 和提交记录判断。

