Astro Docs
This generator scaffolds a documentation site powered by Astro
and the Starlight docs theme. It wires up
localisation, reusable content snippets, locale-aware internal links and a
starlight-blog plugin by default.
By default it also scaffolds an automated translation pipeline powered by a Strands Agent on Amazon Bedrock.
Generate an Astro docs site
Section titled “Generate an Astro docs site”You can generate a new Astro docs site in two ways:
- Install the Nx Console VSCode Plugin if you haven't already
- Open the Nx Console in VSCode
- Click
Generate (UI)in the "Common Nx Commands" section - Search for
@aws/nx-plugin - ts#docs - Fill in the required parameters
- Click
Generate
pnpm nx g @aws/nx-plugin:ts#docsyarn nx g @aws/nx-plugin:ts#docsnpx nx g @aws/nx-plugin:ts#docsbunx nx g @aws/nx-plugin:ts#docsYou can also perform a dry-run to see what files would be changed
pnpm nx g @aws/nx-plugin:ts#docs --dry-runyarn nx g @aws/nx-plugin:ts#docs --dry-runnpx nx g @aws/nx-plugin:ts#docs --dry-runbunx nx g @aws/nx-plugin:ts#docs --dry-runOptions
Section titled “Options”| Parameter | Type | Default | Description |
|---|---|---|---|
| name Required | string | docs | The name of the docs project. |
| directory | string | . | The parent directory the docs project is placed in. |
| subDirectory | string | - | The sub directory the docs project is placed in. Defaults to the kebab-case project name. |
| framework | astro | astro | The documentation framework to use. |
| noTranslation | boolean | Opt out of the automated documentation translation pipeline (Strands Agent on Amazon Bedrock + a `translate` project target). | |
| noBlog | boolean | Opt out of the `starlight-blog` plugin and the sample blog post. | |
| preferInstallDependencies | boolean | true | Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end. |
Generator Output
Section titled “Generator Output”By default the generator creates the following project structure at docs/ in the
workspace root (configurable via the name, directory and subDirectory options):
- astro.config.mjs Astro + Starlight configuration (locales, sidebar, blog plugin)
- tsconfig.json Extends astro/tsconfigs/strict with @components / @assets path aliases
- project.json Nx project with
build,start,preview(andtranslateif enabled) targets Directoryscripts
- translate.ts Translation driver — a Strands agent with a scoped file-editor tool (omitted with
--noTranslation) - translate.config.json Source/target locales, glob patterns, model id, region (omitted with
--noTranslation)
- translate.ts Translation driver — a Strands agent with a scoped file-editor tool (omitted with
Directorysrc
Directorycomponents
- link.astro Locale-aware link component (resolves paths against the current locale)
- snippet.astro Locale-aware snippet loader component
Directorycontent
Directorydocs
Directoryen
- index.mdx Landing page
Directoryguides
- getting-started.mdx Sample guide referencing the link and snippet components
Directoryblog
- welcome.mdx Sample blog post (omitted with
--noBlog)
- welcome.mdx Sample blog post (omitted with
Directorysnippets
- example.mdx Sample reusable snippet
Directorystyles
- custom.css Starlight theme overrides
- README.md Project README
Localisation
Section titled “Localisation”The generator defaults to a single locale (en) and redirects the root URL to
it. To add more languages:
- Add an entry under
localesinastro.config.mjs(for exampleko: { label: '한국어' }). - Create a matching directory under
src/content/docs/<locale>/. - Populate it manually, or use the translation target described below.
Translation
Section titled “Translation”Unless you passed --noTranslation, the generator adds a translate target to
project.json, so you can run:
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-runWhen run without --all, the script only translates files that have changed
since the last translation commit on the current branch — meaning you can
safely re-run it on every docs PR without re-translating the whole site.
Configuring translation
Section titled “Configuring translation”Edit scripts/translate.config.json to change:
| Field | Purpose |
|---|---|
sourceLanguage | Locale to translate from (default en). |
targetLanguages | Locales to translate to. Empty by default. For example ["fr", "de", "es", "ja", "ko"]. |
docsDir | Path to the docs content directory, relative to the project root. |
include | Glob patterns (relative to <docsDir>/<sourceLanguage>) for files to translate. |
exclude | Glob patterns to skip. |
modelId | Bedrock model to use for translations. |
awsRegion | AWS region the Bedrock client is configured with. Can also be set via AWS_REGION. |
concurrency | Max number of concurrent agent invocations. |
translationCommitMessage | Commit message marker for translation commits (default docs: update translations). |
Locale-aware internal links
Section titled “Locale-aware internal links”The generator ships a Link component that automatically resolves internal
docs paths against the current locale, so a single source of truth produces
the right URL in every language:
import Link from '@components/link.astro';
<Link path="guides/getting-started">Read the getting-started guide</Link>Snippets
Section titled “Snippets”Reusable content fragments live in src/content/docs/<locale>/snippets/. The
generated Snippet component loads the snippet that matches the current
locale:
import Snippet from '@components/snippet.astro';
<Snippet name="example" />Wiring up CI
Section titled “Wiring up CI”No CI workflow is generated out of the box — add one that:
-
Configures AWS credentials with permission to invoke Bedrock
InvokeModelon the configured model. -
Runs the
translatetarget on pull requests that touch your source-language docs:Terminal window pnpm nx translate docsTerminal window yarn nx translate docsTerminal window npx nx translate docsTerminal window bunx nx translate docs -
Commits the resulting translations back to the PR branch. The commit message must match the
translationCommitMessagevalue inscripts/translate.config.json(defaultdocs: update translations) so that subsequent incremental runs can detect the baseline commit and only re-translate the files that changed since.