Astro Docs
このジェネレーターは、Astro と Starlight ドキュメントテーマを使用したドキュメントサイトをスキャフォールドします。デフォルトで、ローカライゼーション、再利用可能なコンテンツスニペット、ロケール対応の内部リンク、および starlight-blog プラグインを設定します。
また、デフォルトで Amazon Bedrock 上の Strands Agent を使用した自動翻訳パイプラインもスキャフォールドします。
Astro ドキュメントサイトを生成する
Section titled “Astro ドキュメントサイトを生成する”新しい Astro ドキュメントサイトは2つの方法で生成できます:
- インストール Nx Console VSCode Plugin まだインストールしていない場合
- VSCodeでNxコンソールを開く
- クリック
Generate (UI)"Common Nx Commands"セクションで - 検索
@aws/nx-plugin - ts#astro-docs - 必須パラメータを入力
- クリック
Generate
pnpm nx g @aws/nx-plugin:ts#astro-docsyarn nx g @aws/nx-plugin:ts#astro-docsnpx nx g @aws/nx-plugin:ts#astro-docsbunx nx g @aws/nx-plugin:ts#astro-docs変更されるファイルを確認するためにドライランを実行することもできます
pnpm nx g @aws/nx-plugin:ts#astro-docs --dry-runyarn nx g @aws/nx-plugin:ts#astro-docs --dry-runnpx nx g @aws/nx-plugin:ts#astro-docs --dry-runbunx nx g @aws/nx-plugin:ts#astro-docs --dry-run| パラメータ | 型 | デフォルト | 説明 |
|---|---|---|---|
| name 必須 | string | docs | ドキュメントプロジェクトの名前。 |
| directory | string | . | ドキュメントプロジェクトが配置される親ディレクトリ。 |
| subDirectory | string | - | ドキュメントプロジェクトが配置されるサブディレクトリ。デフォルトはケバブケースのプロジェクト名。 |
| noTranslation | boolean | 自動ドキュメント翻訳パイプライン(Amazon Bedrock上のStrands Agentと`translate`プロジェクトターゲット)をオプトアウトする。 | |
| noBlog | boolean | `starlight-blog`プラグインとサンプルブログ投稿をオプトアウトする。 | |
| skipInstall | boolean | ジェネレーター実行後の依存関係のインストールをスキップする。 |
ジェネレーターの出力
Section titled “ジェネレーターの出力”デフォルトでは、ジェネレーターはワークスペースルートの docs/ に以下のプロジェクト構造を作成します(name、directory、subDirectory オプションで設定可能):
- astro.config.mjs Astro + Starlight の設定(ロケール、サイドバー、ブログプラグイン)
- tsconfig.json @components / @assets パスエイリアスを含む astro/tsconfigs/strict を拡張
- project.json
build、start、preview(有効な場合はtranslate)ターゲットを持つ Nx プロジェクト Directoryscripts
- translate.ts 翻訳ドライバー — スコープ付きファイルエディターツールを持つ Strands エージェント(
--noTranslationで省略) - translate.config.json ソース/ターゲットロケール、glob パターン、モデル ID、リージョン(
--noTranslationで省略)
- translate.ts 翻訳ドライバー — スコープ付きファイルエディターツールを持つ Strands エージェント(
Directorysrc
Directorycomponents
- link.astro ロケール対応リンクコンポーネント(現在のロケールに対してパスを解決)
- snippet.astro ロケール対応スニペットローダーコンポーネント
Directorycontent
Directorydocs
Directoryen
- index.mdx ランディングページ
Directoryguides
- getting-started.mdx リンクとスニペットコンポーネントを参照するサンプルガイド
Directoryblog
- welcome.mdx サンプルブログ投稿(
--noBlogで省略)
- welcome.mdx サンプルブログ投稿(
Directorysnippets
- example.mdx 再利用可能なサンプルスニペット
Directorystyles
- custom.css Starlight テーマのオーバーライド
- README.md プロジェクト README
ローカライゼーション
Section titled “ローカライゼーション”ジェネレーターはデフォルトで単一のロケール(en)を使用し、ルート URL をそこにリダイレクトします。さらに言語を追加するには:
astro.config.mjsのlocalesにエントリを追加します(例:ko: { label: '한국어' })。src/content/docs/<locale>/の下に対応するディレクトリを作成します。- 手動で入力するか、以下で説明する翻訳ターゲットを使用します。
--noTranslation を渡さない限り、ジェネレーターは project.json に translate ターゲットを追加するため、以下を実行できます:
pnpm nx translate docs -- --allpnpm nx translate docs -- --languages jp,kopnpm nx translate docs -- --dry-runyarn nx translate docs -- --allyarn nx translate docs -- --languages jp,koyarn nx translate docs -- --dry-runnpx nx translate docs -- --allnpx nx translate docs -- --languages jp,konpx nx translate docs -- --dry-runbunx nx translate docs -- --allbunx nx translate docs -- --languages jp,kobunx nx translate docs -- --dry-run--all なしで実行すると、スクリプトは現在のブランチで最後の翻訳コミット以降に変更されたファイルのみを翻訳します。つまり、サイト全体を再翻訳することなく、すべてのドキュメント PR で安全に再実行できます。
scripts/translate.config.json を編集して以下を変更します:
| フィールド | 目的 |
|---|---|
sourceLanguage | 翻訳元のロケール(デフォルトは en)。 |
targetLanguages | 翻訳先のロケール。デフォルトでは空です。例:["fr", "de", "es", "ja", "ko"]。 |
docsDir | プロジェクトルートからの相対的なドキュメントコンテンツディレクトリへのパス。 |
include | 翻訳するファイルの glob パターン(<docsDir>/<sourceLanguage> からの相対パス)。 |
exclude | スキップする glob パターン。 |
modelId | 翻訳に使用する Bedrock モデル。 |
awsRegion | Bedrock クライアントが設定されている AWS リージョン。AWS_REGION 経由でも設定可能。 |
concurrency | 同時エージェント呼び出しの最大数。 |
translationCommitMessage | 翻訳コミットのコミットメッセージマーカー(デフォルトは docs: update translations)。 |
ロケール対応の内部リンク
Section titled “ロケール対応の内部リンク”ジェネレーターには、現在のロケールに対して内部ドキュメントパスを自動的に解決する Link コンポーネントが付属しているため、単一の情報源がすべての言語で正しい URL を生成します:
import Link from '@components/link.astro';
<Link path="guides/getting-started">Read the getting-started guide</Link>再利用可能なコンテンツフラグメントは src/content/docs/<locale>/snippets/ にあります。生成された Snippet コンポーネントは、現在のロケールに一致するスニペットを読み込みます:
import Snippet from '@components/snippet.astro';
<Snippet name="example" />CI の設定
Section titled “CI の設定”デフォルトでは CI ワークフローは生成されません。以下を行うワークフローを追加してください:
-
設定されたモデルで Bedrock
InvokeModelを呼び出す権限を持つ AWS 認証情報を設定します。 -
ソース言語のドキュメントに触れるプルリクエストで
translateターゲットを実行します:Terminal window pnpm nx translate docsTerminal window yarn nx translate docsTerminal window npx nx translate docsTerminal window bunx nx translate docs -
結果の翻訳を PR ブランチにコミットバックします。コミットメッセージは
scripts/translate.config.jsonのtranslationCommitMessage値(デフォルトはdocs: update translations)と一致する必要があります。これにより、後続の増分実行がベースラインコミットを検出し、それ以降に変更されたファイルのみを再翻訳できます。