Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/content/docs/zh-cn/guides/content-collections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Astro 提供了 [两个内置的加载器函数(`glob()` 和 `file()`)](/zh-

[`glob()` 加载器](/zh-cn/reference/content-loader-reference/#glob-加载器) 可以从文件系统的任何地方创建 Markdown、MDX、Markdoc、JSON、YAML 或 TOML 文件的目录条目。它基于 [micromatch](https://github.com/micromatch/micromatch#matching-features) 的 glob 模式支持来接受一个匹配条目文件的 `pattern`,以及你的文件所在的 `base` 文件路径。每个条目的 `id` 将从其文件名自动生成。当每个条目对应一个文件时,请使用此加载器。

[`file()` 加载器](/zh-cn/reference/content-loader-reference/#file-加载器) 从单个本地文件创建多个条目。文件中的每个条目必须有一个唯一的 `id` 键属性。它接受一个 相对你的文件的 `base` 文件路径,以及一个可选的 [`parser` 函数](#parser-函数) 用于它无法自动解析的数据文件。当你的数据文件可以解析为对象数组时,请使用此加载器。
[`file()` 加载器](/zh-cn/reference/content-loader-reference/#file-加载器) 从单个本地文件创建多个条目。文件中的每个条目必须有一个唯一的 `id` 键属性。它接受一个相对你的文件的 `base` 文件路径,以及一个可选的 [`parser` 函数](#parser-函数) 用于它无法自动解析的数据文件或用于异步解析数据。当你的数据文件可以解析为对象数组时,请使用此加载器。

```ts title="src/content.config.ts" {6,10}
import { defineCollection } from 'astro:content';
Expand Down