Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n(ja): Update content-collections.mdx for v3 #4396

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
14 changes: 12 additions & 2 deletions src/content/docs/ja/guides/content-collections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,20 @@ const publishedBlogEntries = await getCollection('blog', ({ data }) => {
});
```

開発サーバーの実行時にのみ閲覧可能で、本番用にはビルドされない下書き(draft)ページも作成できます。

```js
// 例: 本番用にビルドするときにのみ、`draft: true`を含むエントリーを除外
import { getCollection } from 'astro:content';
const blogEntries = await getCollection('blog', ({ data }) => {
return import.meta.env.PROD ? data.draft !== true : true;
});
```

filterの引数は、コレクション内の入れ子ディレクトリによるフィルタリングもサポートします。`id`にはネストされた完全なパスが含まれるので、各`id`の先頭でフィルタリングして、特定のネストされたディレクトリからのアイテムだけを返せます。

```js
// 例コレクション内のサブディレクトリによるエントリーのフィルタリング
// 例: コレクション内のサブディレクトリによるエントリーのフィルタリング
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここは関係ありませんが、389 行目と揃えるために修正しました。

import { getCollection } from 'astro:content';
const englishDocsEntries = await getCollection('docs', ({ id }) => {
return id.startsWith('en/');
Expand Down Expand Up @@ -705,7 +715,7 @@ const { Content } = await entry.render();
import rss from "@astrojs/rss";
import { getCollection } from "astro:content";

export async function get() {
export async function GET() {
const posts = await getCollection('posts');
return rss({
title: 'Astro学習者 | ブログ',
Expand Down