Skip to content
Draft
Show file tree
Hide file tree
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
1,061 changes: 1,061 additions & 0 deletions src/content/docs/ja/guides/content-collections.mdx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/content/docs/ja/guides/integrations-guide/markdoc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Markdocファイルは、コンテンツコレクション内でのみ使用で
- quick-start.mdoc
</FileTree>

次に、[コンテンツコレクションAPI](/ja/guides/content-collections/#querying-build-time-collections)を使用してコレクションをクエリします。
次に、[コンテンツコレクションAPI](/ja/guides/content-collections/#ビルド時コレクションのクエリ)を使用してコレクションをクエリします。

```astro title="src/pages/why-markdoc.astro"
---
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/ja/guides/integrations-guide/mdx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ MDXインテグレーションを追加すると、JSX変数、式、コンポ

### コンテンツコレクションでローカルのMDXを使用する

コンテンツコレクションにローカルのMDXファイルを含めるには、[コレクションローダー](/ja/guides/content-collections/#build-time-collection-loaders)が`.mdx`ファイルからコンテンツをロードするように設定されていることを確認してください。
コンテンツコレクションにローカルのMDXファイルを含めるには、[コレクションローダー](/ja/guides/content-collections/#ビルド時コレクションのローダー)が`.mdx`ファイルからコンテンツをロードするように設定されていることを確認してください。

```js title="src/content.config.ts" ins="mdx"
import { defineCollection } from 'astro:content';
Expand Down
8 changes: 4 additions & 4 deletions src/content/docs/ja/guides/markdown-content.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Markdownのコンテンツとフロントマタープロパティは、[ロー

コレクションでは、ファイルインポートではなく、[Markdownコンテンツのクエリとレンダリング](#コンテンツコレクションのクエリから取得したmarkdown)に特化した最適化されたAPIを使用します。コレクションは、ブログ記事や製品情報など、同じ構造を共有するデータセットを対象としています。スキーマでその構造を定義すれば、バリデーション、型安全性、エディタ上のインテリセンスも得られます。

<ReadMore>ファイルインポートの代わりに[コンテンツコレクションを使うべきタイミング](/ja/guides/content-collections/#when-to-create-a-collection)について詳しく見る。</ReadMore>
<ReadMore>ファイルインポートの代わりに[コンテンツコレクションを使うべきタイミング](/ja/guides/content-collections/#コレクションを作成する場合)について詳しく見る。</ReadMore>

## JSXのような動的な式

Expand Down Expand Up @@ -81,7 +81,7 @@ const posts = Object.values(import.meta.glob("./posts/*.md", { eager: true }));

[`render()`](/ja/reference/modules/astro-content/#render)関数は、Markdownの本文、生成された見出しのリスト、およびMarkdownプラグインが適用されたあとの変更済みフロントマターオブジェクトを返します。

<ReadMore>[コレクションのクエリから返されたコンテンツの使い方](/ja/guides/content-collections/#using-content-in-astro-templates)について詳しく見る。</ReadMore>
<ReadMore>[コレクションのクエリから返されたコンテンツの使い方](/ja/guides/content-collections/#astroテンプレートでのコンテンツの使用)について詳しく見る。</ReadMore>

#### Markdownのインポート

Expand Down Expand Up @@ -123,7 +123,7 @@ Astro.props = {

`<Content />`コンポーネントは、Markdownファイルから`Content`をインポートすることで利用できます。このコンポーネントは、ファイルの本文全体をHTMLにレンダリングして返します。`Content`は好みの名前にリネームすることもできます。

同様に、`<Content />`コンポーネントをレンダリングすることで、[Markdownコレクションエントリの本文をHTMLとしてレンダリング](/ja/guides/content-collections/#rendering-body-content)できます。
同様に、`<Content />`コンポーネントをレンダリングすることで、[Markdownコレクションエントリの本文をHTMLとしてレンダリング](/ja/guides/content-collections/#本文コンテンツのレンダリング)できます。

```astro title="src/pages/content.astro" "Content"
---
Expand Down Expand Up @@ -505,7 +505,7 @@ const {frontmatter} = Astro.props;

Astro内部のMarkdownプロセッサは、リモートのMarkdownを処理するためには利用できません。

[コンテンツコレクション](/ja/guides/content-collections/)で使うためにリモートのMarkdownを取得するには、[`renderMarkdown()`関数](/ja/reference/content-loader-reference/#loadercontextrendermarkdown)にアクセスできる[カスタムローダーを作成](/ja/guides/content-collections/#custom-build-time-loaders)します。
[コンテンツコレクション](/ja/guides/content-collections/)で使うためにリモートのMarkdownを取得するには、[`renderMarkdown()`関数](/ja/reference/content-loader-reference/#loadercontextrendermarkdown)にアクセスできる[カスタムローダーを作成](/ja/guides/content-collections/#独自のビルド時ローダー)します。

リモートのMarkdownを直接取得してHTMLにレンダリングするには、NPMから自分でMarkdownパーサーをインストールして設定する必要があります。この場合、Astro組み込みのMarkdown設定は引き継がれません。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ const randomUser = data.results[0];
---
```

詳細は[`import.meta.glob()`](/ja/guides/imports/#importmetaglob)によるローカルファイルの読み込み、[コンテンツコレクションのクエリ](/ja/guides/content-collections/#querying-build-time-collections)、[リモートデータの取得](/ja/guides/data-fetching/)の各ガイドを参照してください。
詳細は[`import.meta.glob()`](/ja/guides/imports/#importmetaglob)によるローカルファイルの読み込み、[コンテンツコレクションのクエリ](/ja/guides/content-collections/#ビルド時コレクションのクエリ)、[リモートデータの取得](/ja/guides/data-fetching/)の各ガイドを参照してください。

### CRAのスタイリングをAstroへ

Expand Down
6 changes: 3 additions & 3 deletions src/content/docs/ja/guides/upgrade-to/v6.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ import { defineCollection } from "astro:content"
import { z } from "astro/zod"
```

<ReadMore>[Zodを使用したコレクションスキーマの定義](/ja/guides/content-collections/#defining-datatypes-with-zod)の詳細を確認してください。</ReadMore>
<ReadMore>[Zodを使用したコレクションスキーマの定義](/ja/guides/content-collections/#zodによるデータ型の定義)の詳細を確認してください。</ReadMore>

### 非推奨: `astro:transitions`の内部API

Expand Down Expand Up @@ -583,7 +583,7 @@ v6へのアップグレード後に[コンテンツコレクションのエラ

<details>
<summary>コンテンツコレクションの設定ファイルがない</summary>
`src/content.config.ts`を作成し、その中で[コレクションを定義](/ja/guides/content-collections/#defining-build-time-content-collections)してください。
`src/content.config.ts`を作成し、その中で[コレクションを定義](/ja/guides/content-collections/#ビルド時コンテンツコレクションの定義)してください。
</details>

<details>
Expand All @@ -594,7 +594,7 @@ v6へのアップグレード後に[コンテンツコレクションのエラ
<details>
<summary>`loader`が定義されていないコレクション([`ContentCollectionMissingALoaderError`](/ja/reference/errors/content-collection-missing-loader/))</summary>

[Astro組み込みの`glob()`ローダー](/ja/guides/content-collections/#the-glob-loader)をインポートし、コレクションエントリーの`pattern`と`base`を定義してください。
[Astro組み込みの`glob()`ローダー](/ja/guides/content-collections/#globローダー)をインポートし、コレクションエントリーの`pattern`と`base`を定義してください。

```ts ins={4,7}
// src/content.config.ts
Expand Down
6 changes: 3 additions & 3 deletions src/content/docs/ja/tutorial/6-islands/4.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { Steps } from '@astrojs/starlight/components';

コンテンツコレクションを使う場合でも、`src/pages/`フォルダーは「About Me」ページのような、個別のページ用には引き続き使います。ただし、ブログ記事をこの特別なフォルダーの外に移すことで、ブログ一覧の生成や各記事の表示に、より強力でパフォーマンスの高いAPIが使えるようになります。

同時に、各記事に共通する構造を定義する **[スキーマ](/ja/guides/content-collections/#defining-the-collection-schema)** を用意でき、Astroが[Zod](https://zod.dev/)(TypeScript向けのスキーマ宣言・検証ライブラリ)を通じてその構造どおりかどうかを検証してくれることで、コードエディター上でもより的確なガイドや補完を受けられるようになります。スキーマでは、説明や著者などのフロントマターのプロパティを必須にするかどうか、文字列や配列などの各プロパティの型を何にするかを指定できます。結果として、多くの間違いを早い段階で発見でき、問題箇所をはっきり示すエラーメッセージが得られます。
同時に、各記事に共通する構造を定義する **[スキーマ](/ja/guides/content-collections/#コレクションスキーマの定義)** を用意でき、Astroが[Zod](https://zod.dev/)(TypeScript向けのスキーマ宣言・検証ライブラリ)を通じてその構造どおりかどうかを検証してくれることで、コードエディター上でもより的確なガイドや補完を受けられるようになります。スキーマでは、説明や著者などのフロントマターのプロパティを必須にするかどうか、文字列や配列などの各プロパティの型を何にするかを指定できます。結果として、多くの間違いを早い段階で発見でき、問題箇所をはっきり示すエラーメッセージが得られます。

詳しくはガイドの[Astroのコンテンツコレクション](/ja/guides/content-collections/)を読むか、以下の手順に沿って、基本的なブログを`src/pages/posts/`から`src/blog/`へ移行してみてください。

Expand Down Expand Up @@ -113,7 +113,7 @@ import { Steps } from '@astrojs/starlight/components';

2. 既存のブログ記事(`.md`ファイル)をすべて`src/pages/posts/`から、この新しいコレクションへ移動します。

3. `postsCollection`用の[スキーマを定義する](/ja/guides/content-collections/#defining-the-collection-schema)ために`src/content.config.ts`ファイルを作成します。既存のブログチュートリアルのコードに合わせ、記事のフロントマターで使っているプロパティをすべて定義するために、次の内容をファイルに追加します。
3. `postsCollection`用の[スキーマを定義する](/ja/guides/content-collections/#コレクションスキーマの定義)ために`src/content.config.ts`ファイルを作成します。既存のブログチュートリアルのコードに合わせ、記事のフロントマターで使っているプロパティをすべて定義するために、次の内容をファイルに追加します。

```ts title="src/content.config.ts"
// glob ローダーをインポートする
Expand Down Expand Up @@ -149,7 +149,7 @@ import { Steps } from '@astrojs/starlight/components';
<Steps>
1. `src/pages/posts/[...slug].astro`という名前のページファイルを作成します。コレクション内に置いたMarkdownやMDXは、Astroのファイルベースルーティングでは自動的にはページになりません。そのため、各ブログ記事を生成するためのページを自分で用意する必要があります。

2. 次のコードを追加して[コレクションをクエリし](/ja/guides/content-collections/#querying-build-time-collections)、生成する各ページでスラッグと記事本文が使えるようにします。
2. 次のコードを追加して[コレクションをクエリし](/ja/guides/content-collections/#ビルド時コレクションのクエリ)、生成する各ページでスラッグと記事本文が使えるようにします。

```astro title="src/pages/posts/[...slug].astro"
---
Expand Down
Loading