# @ascorbic/airtable-loader 中文文档

规范地址：https://npmcn.com/package/%40ascorbic/airtable-loader/

版本：1\.0\.5
npm 元数据更新时间：2024-11-17T10:49:32.174Z
中文译文更新时间：2026-11-06T22:35:20.750Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40ascorbic/airtable-loader
原文对照：https://npmcn.com/package/%40ascorbic/airtable-loader/?lang=original
项目主页：https://github.com/ascorbic/astro-loaders
源码仓库：https://github.com/ascorbic/astro-loaders

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

- 包体积（解压后）：9.7 kB，4 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：3 个
- peer 依赖：astro ^4\.14\.0 \|\| ^5\.0\.0-beta\.0
- 首次发布：2024-08-10T21:43:34.915Z
- 最新版本发布：2024-11-17T10:49:32.007Z
- 近 30 天下载量：12716（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：8（近 12 个月 0 个）

## 中文简介

这个包件为Astro提供了一台气表装载机. 它允许您从一个 Airtable 基地装入记录,并在您的 Astro 计划中将其作为内容.

## 安装

```sh
npm install @ascorbic/airtable-loader
```

也可以使用：`pnpm add @ascorbic/airtable-loader`、`yarn add @ascorbic/airtable-loader`、`bun add @ascorbic/airtable-loader`

## README

# Astro 气压装载机

这个包件为Astro提供了一台气表装载机. 它允许您从一个 Airtable 基地装入记录,并在您的 Astro 计划中将其作为内容.

## 安装

```sh
npm install @ascorbic/airtable-loader
```

## 使用量

这个包需要Astro 4.14.0或以后. 您必须启用Astro的实验内容层, 除非您正在使用5. 0.0- beta 版本或稍后使用 。 你可以这样做,在你的 `astro.config.mjs`数字 :

```javascript
export default defineConfig({
  // ...
  experimental: {
    contentLayer: true,
  },
});
```

您需要创建 Airtable 个人访问标志 。 您可以创建一个 [这里](https://airtable.com/create/tokens)。 。 。 .

您应该确保此标志能够访问您想要使用的基数,并具有以下范围:

-   `data.records:read`
-   `schema.bases:read`

然后可以在内容收集配置中使用种子加载器 :

```typescript
// src/content/config.ts
import { defineCollection } from "astro:content";
import { airtableLoader } from "@ascorbic/airtable-loader";

const launches = defineCollection({
  loader: airtableLoader({
    base: import.meta.env.AIRTABLE_BASE,
    table: "Product Launches",
  }),
});

export const collections = { launches };
```

然后,您可以像Astro的其他内容收藏一样使用这些内容. 数据是安全的类型,类型会根据"空气表"的"计划"自动生成.

```astro
---
import type { GetStaticPaths } from "astro";
import { getCollection, type CollectionEntry } from "astro:content";
import Layout from "../../layouts/Layout.astro";

export const getStaticPaths: GetStaticPaths = async () => {
  const launches = await getCollection("launches");
  return launches.map((launch) => ({
    params: {
      id: launch.id,
    },
    props: { launch },
  }));
};

type Props = { launch: CollectionEntry<"launches"> };

const { launch } = Astro.props;
const { data } = launch;
---

<Layout title={data.firstName}>
  <h1>{data["Launch Name"]}</h1>
  <p>{data["Launch date"]?.toDateString()}</p>
  <p>{data.Description}</p>
</Layout>

```

## 选项

这个 `airtableLoader` 函数取一个对象,其选项如下:

-   `base`: AirTable 基地的ID 您想要从中装入记录.
-   `table`:要从底部装入记录的表格名称或标识.
-   `token`:你的空中个人访问标志。 如果不提供,请从 `AIRTABLE_TOKEN` 环境变量.
-   `queryParams`:可选对象,可选择通过Airtable API. 这可以用来过滤或限制返回的记录. 见 [空中查询文件](https://airtable.com/developers/web/api/list-records#query) 更多信息.

## 常见问题

### @ascorbic/airtable-loader 是什么？

这个包件为Astro提供了一台气表装载机\. 它允许您从一个 Airtable 基地装入记录,并在您的 Astro 计划中将其作为内容\.

### 如何安装 @ascorbic/airtable-loader？

在项目目录运行 npm install @ascorbic/airtable-loader，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：astro（^4\.14\.0 \|\| ^5\.0\.0-beta\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @ascorbic/airtable-loader 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @ascorbic/airtable-loader 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @ascorbic/airtable-loader 可以商用吗？

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

### @ascorbic/airtable-loader 的下载量有多少？

根据 npm 官方下载统计，@ascorbic/airtable-loader 在 2026/10/07 – 2026/11/05 这 30 天内被下载 12,716 次，日均约 424 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @ascorbic/airtable-loader 还在维护吗？

最新版本 1\.0\.5 发布于 2024/11/17（2 年前）；至今共发布 8 个版本，其中过去 12 个月发布了 0 个；首次发布于 2024/08/11。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

