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
67 changes: 67 additions & 0 deletions src/content/docs/ko/guides/content-collections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,73 @@ const { Content } = await render(post);
[GitHub의 블로그 튜토리얼 데모 코드](https://github.com/withastro/blog-tutorial-demo/tree/content-collections/src/pages)의 `src/pages/` 폴더를 살펴보면 블로그 게시물 목록, 태그 페이지 등과 같은 블로그 기능을 위해 컬렉션으로부터 페이지를 생성하는 전체 예시를 확인할 수 있습니다!
:::

## 컬렉션 JSON 스키마

<p><Since v="4.13.0" /></p>

Astro는 컬렉션용 [JSON 스키마](https://json-schema.org/) 파일을 자동으로 생성하며, 이를 편집기에서 사용하면 데이터 파일에 대한 IntelliSense 및 타입 검사를 받을 수 있습니다.

프로젝트의 각 컬렉션에 대해 JSON 스키마 파일이 생성되어 `.astro/collections/` 디렉터리에 출력됩니다.
예를 들어, `authors`와 `posts`라는 두 컬렉션이 있다면, Astro는 `.astro/collections/authors.schema.json`와 `.astro/collections/posts.schema.json`을 생성합니다.

### JSON 파일에서 JSON 스키마 사용하기

JSON 파일에서 `$schema` 필드를 설정하여 Astro가 생성한 스키마를 직접 지정할 수 있습니다.
값은 데이터 파일에서 스키마까지의 상대 파일 경로여야 합니다.
다음은 `src/data/authors/`에 있는 데이터 파일이 `authors` 컬렉션용으로 생성된 스키마를 사용하는 예시입니다.

```json title="src/data/authors/armand.json" ins={2}
{
"$schema": "../../../.astro/collections/authors.schema.json",
"name": "Armand",
"skills": ["Astro", "Starlight"]
}
```

#### VS Code에서 JSON 파일 그룹에 스키마 사용하기

VS Code에서 [`json.schemas` 설정](https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings)을 사용하여 컬렉션 내 모든 파일에 적용할 스키마를 구성할 수 있습니다.
다음은 `src/data/authors/` 디렉터리 내 모든 파일이 `authors` 컬렉션용으로 생성된 스키마를 사용하는 예시입니다.

```json
{
"json.schemas": [
{
"fileMatch": ["/src/data/authors/**"],
"url": "./.astro/collections/authors.schema.json"
}
]
}
```

### VS Code에서 YAML 파일의 스키마 사용하기

VS Code에서 [Red Hat YAML](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) 확장 기능을 사용하면 YAML 파일에서 JSON 스키마를 사용할 수 있습니다.
이 확장 기능을 설치하면 특수 주석 구문을 사용하여 YAML 파일에서 스키마를 참조할 수 있습니다.

```yaml title="src/data/authors/armand.yml" ins={1}
# yaml-language-server: $schema=../../../.astro/collections/authors.schema.json
name: Armand
skills:
- Astro
- Starlight
```

#### VS Code에서 YAML 파일 그룹에 스키마 사용하기

Red Hat YAML 확장 기능을 사용하면 `yaml.schemas` 설정을 통해 컬렉션 내 모든 YAML 파일에 적용할 스키마를 구성할 수 있습니다.
다음은 `src/data/authors/` 디렉터리 내 모든 YAML 파일이 `authors` 컬렉션용으로 생성된 스키마를 사용하는 예시입니다.

```json
{
"yaml.schemas": {
"./.astro/collections/authors.schema.json": ["/src/content/authors/*.yml"]
}
}
```

자세한 내용은 Red Hat YAML 확장 기능 문서의 [“Associating schemas”](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml#associating-schemas)를 참조하세요.

## 컬렉션 생성이 필요한 경우

관련된 데이터나 콘텐츠가 공통 구조를 공유하는 그룹이 있을 때마다 [컬렉션을 생성](#컬렉션-정의)할 수 있습니다.
Expand Down