@aws/nx-plugin 0.100.0 → 0.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generators.json +26 -19
- package/package.json +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/ts/astro-docs/__snapshots__/generator.spec.ts.snap +223 -0
- package/src/ts/astro-docs/files/base/README.md.template +63 -0
- package/src/ts/astro-docs/files/base/astro.config.mjs.template +47 -0
- package/src/ts/astro-docs/files/base/src/components/link.astro.template +25 -0
- package/src/ts/astro-docs/files/base/src/components/snippet.astro.template +20 -0
- package/src/ts/astro-docs/files/base/src/content/docs/en/blog/welcome.mdx.template +13 -0
- package/src/ts/astro-docs/files/base/src/content/docs/en/guides/getting-started.mdx.template +64 -0
- package/src/ts/astro-docs/files/base/src/content/docs/en/index.mdx.template +29 -0
- package/src/ts/astro-docs/files/base/src/content/docs/en/snippets/example.mdx.template +7 -0
- package/src/ts/astro-docs/files/base/src/content.config.ts.template +13 -0
- package/src/ts/astro-docs/files/base/src/styles/custom.css.template +1 -0
- package/src/ts/astro-docs/files/base/tsconfig.json.template +12 -0
- package/src/ts/astro-docs/files/translation/scripts/translate.config.json.template +10 -0
- package/src/ts/astro-docs/files/translation/scripts/translate.ts.template +430 -0
- package/src/ts/astro-docs/generator.d.ts +10 -0
- package/src/ts/astro-docs/generator.js +113 -0
- package/src/ts/astro-docs/generator.js.map +1 -0
- package/src/ts/astro-docs/schema.d.ts +30 -0
- package/src/ts/astro-docs/schema.json +62 -0
- package/src/utils/versions.d.ts +13 -1
- package/src/utils/versions.js +12 -0
- package/src/utils/versions.js.map +1 -1
package/generators.json
CHANGED
|
@@ -103,6 +103,20 @@
|
|
|
103
103
|
"description": "Add a Strands Agent to a Python project",
|
|
104
104
|
"metric": "g25"
|
|
105
105
|
},
|
|
106
|
+
"py#strands-agent#mcp-connection": {
|
|
107
|
+
"factory": "./src/py/strands-agent/mcp-connection/generator",
|
|
108
|
+
"schema": "./src/py/strands-agent/mcp-connection/schema.json",
|
|
109
|
+
"description": "Connect a Python Strands Agent to an MCP server",
|
|
110
|
+
"metric": "g32",
|
|
111
|
+
"hidden": true
|
|
112
|
+
},
|
|
113
|
+
"py#strands-agent#react-connection": {
|
|
114
|
+
"factory": "./src/py/strands-agent/react-connection/generator",
|
|
115
|
+
"schema": "./src/py/strands-agent/react-connection/schema.json",
|
|
116
|
+
"description": "Connect a React website to a Python Strands Agent",
|
|
117
|
+
"metric": "g34",
|
|
118
|
+
"hidden": true
|
|
119
|
+
},
|
|
106
120
|
"smithy#project": {
|
|
107
121
|
"factory": "./src/smithy/project/generator",
|
|
108
122
|
"schema": "./src/smithy/project/schema.json",
|
|
@@ -124,6 +138,13 @@
|
|
|
124
138
|
"metric": "g23",
|
|
125
139
|
"guidePages": ["terraform-project"]
|
|
126
140
|
},
|
|
141
|
+
"ts#astro-docs": {
|
|
142
|
+
"factory": "./src/ts/astro-docs/generator",
|
|
143
|
+
"schema": "./src/ts/astro-docs/schema.json",
|
|
144
|
+
"description": "Generates an Astro + Starlight documentation site with localisation, snippets, blog, and optional automated documentation translation",
|
|
145
|
+
"metric": "g37",
|
|
146
|
+
"guidePages": ["astro-docs"]
|
|
147
|
+
},
|
|
127
148
|
"ts#infra": {
|
|
128
149
|
"factory": "./src/infra/app/generator",
|
|
129
150
|
"schema": "./src/infra/app/schema.json",
|
|
@@ -196,13 +217,6 @@
|
|
|
196
217
|
"description": "Add a Strands Agent to a TypeScript project",
|
|
197
218
|
"metric": "g30"
|
|
198
219
|
},
|
|
199
|
-
"ts#strands-agent#react-connection": {
|
|
200
|
-
"factory": "./src/ts/strands-agent/react-connection/generator",
|
|
201
|
-
"schema": "./src/ts/strands-agent/react-connection/schema.json",
|
|
202
|
-
"description": "Connect a React website to a TypeScript Strands Agent",
|
|
203
|
-
"metric": "g33",
|
|
204
|
-
"hidden": true
|
|
205
|
-
},
|
|
206
220
|
"ts#strands-agent#mcp-connection": {
|
|
207
221
|
"factory": "./src/ts/strands-agent/mcp-connection/generator",
|
|
208
222
|
"schema": "./src/ts/strands-agent/mcp-connection/schema.json",
|
|
@@ -210,11 +224,11 @@
|
|
|
210
224
|
"metric": "g31",
|
|
211
225
|
"hidden": true
|
|
212
226
|
},
|
|
213
|
-
"
|
|
214
|
-
"factory": "./src/
|
|
215
|
-
"schema": "./src/
|
|
216
|
-
"description": "Connect a
|
|
217
|
-
"metric": "
|
|
227
|
+
"ts#strands-agent#react-connection": {
|
|
228
|
+
"factory": "./src/ts/strands-agent/react-connection/generator",
|
|
229
|
+
"schema": "./src/ts/strands-agent/react-connection/schema.json",
|
|
230
|
+
"description": "Connect a React website to a TypeScript Strands Agent",
|
|
231
|
+
"metric": "g33",
|
|
218
232
|
"hidden": true
|
|
219
233
|
},
|
|
220
234
|
"ts#strands-agent#a2a-connection": {
|
|
@@ -231,13 +245,6 @@
|
|
|
231
245
|
"metric": "g36",
|
|
232
246
|
"hidden": true
|
|
233
247
|
},
|
|
234
|
-
"py#strands-agent#react-connection": {
|
|
235
|
-
"factory": "./src/py/strands-agent/react-connection/generator",
|
|
236
|
-
"schema": "./src/py/strands-agent/react-connection/schema.json",
|
|
237
|
-
"description": "Connect a React website to a Python Strands Agent",
|
|
238
|
-
"metric": "g34",
|
|
239
|
-
"hidden": true
|
|
240
|
-
},
|
|
241
248
|
"ts#sync": {
|
|
242
249
|
"factory": "./src/ts/sync/generator",
|
|
243
250
|
"schema": "./src/ts/sync/schema.json",
|
package/package.json
CHANGED
|
@@ -46,6 +46,8 @@ The following list of generators are what is currently available in the \`@aws/n
|
|
|
46
46
|
|
|
47
47
|
- **terraform#project**: Generates a Terraform project
|
|
48
48
|
|
|
49
|
+
- **ts#astro-docs**: Generates an Astro + Starlight documentation site with localisation, snippets, blog, and optional automated documentation translation
|
|
50
|
+
|
|
49
51
|
- **ts#infra**: Generates a cdk application
|
|
50
52
|
|
|
51
53
|
- **ts#lambda-function**: Generate a TypeScript lambda function
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`ts#astro-docs generator > should generate a docs site with default options (translation + blog enabled) > astro.config.mjs 1`] = `
|
|
4
|
+
"// @ts-check
|
|
5
|
+
import { defineConfig } from 'astro/config';
|
|
6
|
+
|
|
7
|
+
import starlight from '@astrojs/starlight';
|
|
8
|
+
import starlightBlog from 'starlight-blog';
|
|
9
|
+
|
|
10
|
+
// https://astro.build/config
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
outDir: './dist',
|
|
13
|
+
// Redirect the root URL to the default locale so visitors land on localised content.
|
|
14
|
+
redirects: {
|
|
15
|
+
'/': '/en',
|
|
16
|
+
},
|
|
17
|
+
integrations: [
|
|
18
|
+
starlight({
|
|
19
|
+
title: 'docs',
|
|
20
|
+
social: [],
|
|
21
|
+
tableOfContents: {
|
|
22
|
+
minHeadingLevel: 2,
|
|
23
|
+
maxHeadingLevel: 4,
|
|
24
|
+
},
|
|
25
|
+
defaultLocale: 'en',
|
|
26
|
+
locales: {
|
|
27
|
+
en: {
|
|
28
|
+
label: 'English',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
sidebar: [
|
|
32
|
+
{
|
|
33
|
+
label: 'Getting started',
|
|
34
|
+
items: [{ slug: 'guides/getting-started' }],
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
customCss: ['./src/styles/custom.css'],
|
|
38
|
+
plugins: [
|
|
39
|
+
starlightBlog({
|
|
40
|
+
authors: {
|
|
41
|
+
default: {
|
|
42
|
+
name: 'Docs Author',
|
|
43
|
+
title: 'Maintainer',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
],
|
|
48
|
+
}),
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
"
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
exports[`ts#astro-docs generator > should generate a docs site with default options (translation + blog enabled) > index.mdx 1`] = `
|
|
55
|
+
"---
|
|
56
|
+
title: docs
|
|
57
|
+
description: Documentation for docs.
|
|
58
|
+
template: splash
|
|
59
|
+
hero:
|
|
60
|
+
title: docs
|
|
61
|
+
tagline: Project documentation built with Astro and Starlight.
|
|
62
|
+
actions:
|
|
63
|
+
- text: Get started
|
|
64
|
+
link: /en/guides/getting-started
|
|
65
|
+
icon: right-arrow
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
import { CardGrid, Card } from '@astrojs/starlight/components';
|
|
69
|
+
|
|
70
|
+
<CardGrid>
|
|
71
|
+
<Card title="Guides" icon="open-book">
|
|
72
|
+
Reference documentation for docs.
|
|
73
|
+
</Card>
|
|
74
|
+
<Card title="Blog" icon="pencil">
|
|
75
|
+
News and updates from the team.
|
|
76
|
+
</Card>
|
|
77
|
+
<Card title="Snippets" icon="seti:config">
|
|
78
|
+
Reusable content fragments used across the docs.
|
|
79
|
+
</Card>
|
|
80
|
+
<Card title="Localised" icon="translate">
|
|
81
|
+
Localisation is configured out of the box — add target locales in
|
|
82
|
+
\`astro.config.mjs\`.
|
|
83
|
+
</Card>
|
|
84
|
+
</CardGrid>
|
|
85
|
+
"
|
|
86
|
+
`;
|
|
87
|
+
|
|
88
|
+
exports[`ts#astro-docs generator > should generate a docs site with default options (translation + blog enabled) > link.astro 1`] = `
|
|
89
|
+
"---
|
|
90
|
+
import { getRelativeLocaleUrl } from 'astro:i18n';
|
|
91
|
+
import { LinkButton } from '@astrojs/starlight/components';
|
|
92
|
+
|
|
93
|
+
// Resolve an internal docs path against the current locale so a single source of
|
|
94
|
+
// truth (the \`path\` prop) produces a correct URL in every language. Callers pass
|
|
95
|
+
// a locale-agnostic path like \`guides/getting-started\`.
|
|
96
|
+
const { path, type } = Astro.props;
|
|
97
|
+
let resolvedPath = getRelativeLocaleUrl(Astro.currentLocale || 'en', path);
|
|
98
|
+
if (resolvedPath.endsWith('/')) {
|
|
99
|
+
resolvedPath = resolvedPath.slice(0, -1);
|
|
100
|
+
}
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
{
|
|
104
|
+
type === 'button' ? (
|
|
105
|
+
<LinkButton href={resolvedPath}>
|
|
106
|
+
<slot />
|
|
107
|
+
</LinkButton>
|
|
108
|
+
) : (
|
|
109
|
+
<a href={resolvedPath}>
|
|
110
|
+
<slot />
|
|
111
|
+
</a>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
"
|
|
115
|
+
`;
|
|
116
|
+
|
|
117
|
+
exports[`ts#astro-docs generator > should generate a docs site with default options (translation + blog enabled) > project.json 1`] = `
|
|
118
|
+
"{
|
|
119
|
+
"name": "@proj/docs",
|
|
120
|
+
"$schema": "../node_modules/nx/schemas/project-schema.json",
|
|
121
|
+
"sourceRoot": "docs/src",
|
|
122
|
+
"projectType": "application",
|
|
123
|
+
"targets": {
|
|
124
|
+
"build": {
|
|
125
|
+
"executor": "nx:run-commands",
|
|
126
|
+
"options": {
|
|
127
|
+
"command": "astro build",
|
|
128
|
+
"cwd": "docs"
|
|
129
|
+
},
|
|
130
|
+
"outputs": ["{workspaceRoot}/docs/dist"],
|
|
131
|
+
"cache": true
|
|
132
|
+
},
|
|
133
|
+
"start": {
|
|
134
|
+
"executor": "nx:run-commands",
|
|
135
|
+
"options": {
|
|
136
|
+
"command": "astro dev",
|
|
137
|
+
"cwd": "docs"
|
|
138
|
+
},
|
|
139
|
+
"continuous": true
|
|
140
|
+
},
|
|
141
|
+
"serve": {
|
|
142
|
+
"dependsOn": ["start"]
|
|
143
|
+
},
|
|
144
|
+
"preview": {
|
|
145
|
+
"executor": "nx:run-commands",
|
|
146
|
+
"options": {
|
|
147
|
+
"command": "astro preview",
|
|
148
|
+
"cwd": "docs"
|
|
149
|
+
},
|
|
150
|
+
"dependsOn": ["build"],
|
|
151
|
+
"continuous": true
|
|
152
|
+
},
|
|
153
|
+
"translate": {
|
|
154
|
+
"executor": "nx:run-commands",
|
|
155
|
+
"options": {
|
|
156
|
+
"command": "tsx ./scripts/translate.ts",
|
|
157
|
+
"cwd": "docs",
|
|
158
|
+
"forwardAllArgs": true
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"metadata": {
|
|
163
|
+
"generator": "ts#astro-docs",
|
|
164
|
+
"includeTranslation": true,
|
|
165
|
+
"includeBlog": true
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
"
|
|
169
|
+
`;
|
|
170
|
+
|
|
171
|
+
exports[`ts#astro-docs generator > should generate a docs site with default options (translation + blog enabled) > snippet.astro 1`] = `
|
|
172
|
+
"---
|
|
173
|
+
import { Aside } from '@astrojs/starlight/components';
|
|
174
|
+
|
|
175
|
+
const locale = Astro.currentLocale || 'en';
|
|
176
|
+
const snippets = Object.values(
|
|
177
|
+
import.meta.glob('../content/docs/*/snippets/**/*.mdx', { eager: true })
|
|
178
|
+
);
|
|
179
|
+
const { name } = Astro.props;
|
|
180
|
+
const snippet = snippets.find((s) =>
|
|
181
|
+
s.file.endsWith(\`content/docs/\${locale}/snippets/\${name}.mdx\`)
|
|
182
|
+
);
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
{
|
|
186
|
+
snippet ? (
|
|
187
|
+
<snippet.Content />
|
|
188
|
+
) : (
|
|
189
|
+
<Aside type="danger">Unable to load snippet {name} for locale {locale}</Aside>
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
"
|
|
193
|
+
`;
|
|
194
|
+
|
|
195
|
+
exports[`ts#astro-docs generator > should generate a docs site with default options (translation + blog enabled) > translate.config.json 1`] = `
|
|
196
|
+
"{
|
|
197
|
+
"sourceLanguage": "en",
|
|
198
|
+
"targetLanguages": [],
|
|
199
|
+
"docsDir": "src/content/docs",
|
|
200
|
+
"include": ["**/*.md", "**/*.mdx"],
|
|
201
|
+
"exclude": [],
|
|
202
|
+
"modelId": "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
|
|
203
|
+
"awsRegion": "us-west-2",
|
|
204
|
+
"concurrency": 5
|
|
205
|
+
}
|
|
206
|
+
"
|
|
207
|
+
`;
|
|
208
|
+
|
|
209
|
+
exports[`ts#astro-docs generator > should generate a docs site with default options (translation + blog enabled) > tsconfig.json 1`] = `
|
|
210
|
+
"{
|
|
211
|
+
"extends": "astro/tsconfigs/strict",
|
|
212
|
+
"include": [".astro/types.d.ts", "**/*"],
|
|
213
|
+
"exclude": ["dist"],
|
|
214
|
+
"compilerOptions": {
|
|
215
|
+
"baseUrl": ".",
|
|
216
|
+
"paths": {
|
|
217
|
+
"@components/*": ["src/components/*"],
|
|
218
|
+
"@assets/*": ["src/content/docs/assets/*"]
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
"
|
|
223
|
+
`;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# <%= fullyQualifiedName %>
|
|
2
|
+
|
|
3
|
+
Documentation site generated with [@aws/nx-plugin](https://github.com/awslabs/nx-plugin-for-aws/),
|
|
4
|
+
powered by [Astro](https://astro.build/) and [Starlight](https://starlight.astro.build/).
|
|
5
|
+
|
|
6
|
+
## Run locally
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
<%= pkgMgrCmd %> nx start <%= fullyQualifiedName %>
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Build for production
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
<%= pkgMgrCmd %> nx build <%= fullyQualifiedName %>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Preview the production build
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
<%= pkgMgrCmd %> nx preview <%= fullyQualifiedName %>
|
|
22
|
+
```
|
|
23
|
+
<% if (includeTranslation) { %>
|
|
24
|
+
## Translate documentation
|
|
25
|
+
|
|
26
|
+
This project is pre-wired with a translation script that uses a
|
|
27
|
+
[Strands Agent](https://strandsagents.com/) powered by Claude on
|
|
28
|
+
[Amazon Bedrock](https://aws.amazon.com/bedrock/) to translate documentation from
|
|
29
|
+
the source language (`en` by default) into every locale listed in
|
|
30
|
+
`scripts/translate.config.json`.
|
|
31
|
+
|
|
32
|
+
By default the `targetLanguages` list is empty — add the locale codes you want
|
|
33
|
+
to ship, for example:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
"targetLanguages": ["fr", "de", "es", "ja", "ko"]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Make sure each locale you list is also configured in `astro.config.mjs` under
|
|
40
|
+
`locales`.
|
|
41
|
+
|
|
42
|
+
Run the translator manually with:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
<%= pkgMgrCmd %> nx translate <%= fullyQualifiedName %> -- --all
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Translate only the files that changed since the last `docs: update translations`
|
|
49
|
+
commit:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
<%= pkgMgrCmd %> nx translate <%= fullyQualifiedName %>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Other options in `scripts/translate.config.json`:
|
|
56
|
+
|
|
57
|
+
- `include` / `exclude` — glob patterns for docs files, relative to the source
|
|
58
|
+
language directory.
|
|
59
|
+
- `modelId` — Bedrock model id.
|
|
60
|
+
- `awsRegion` — Bedrock region; can be overridden with the `AWS_REGION` env var.
|
|
61
|
+
- `concurrency` — cap on concurrent Bedrock requests (one agent per file ×
|
|
62
|
+
target language).
|
|
63
|
+
<% } %>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { defineConfig } from 'astro/config';
|
|
3
|
+
|
|
4
|
+
import starlight from '@astrojs/starlight';
|
|
5
|
+
<% if (includeBlog) { %>import starlightBlog from 'starlight-blog';
|
|
6
|
+
<% } %>
|
|
7
|
+
// https://astro.build/config
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
outDir: './dist',
|
|
10
|
+
// Redirect the root URL to the default locale so visitors land on localised content.
|
|
11
|
+
redirects: {
|
|
12
|
+
'/': '/en',
|
|
13
|
+
},
|
|
14
|
+
integrations: [
|
|
15
|
+
starlight({
|
|
16
|
+
title: '<%= title %>',
|
|
17
|
+
social: [],
|
|
18
|
+
tableOfContents: {
|
|
19
|
+
minHeadingLevel: 2,
|
|
20
|
+
maxHeadingLevel: 4,
|
|
21
|
+
},
|
|
22
|
+
defaultLocale: 'en',
|
|
23
|
+
locales: {
|
|
24
|
+
en: {
|
|
25
|
+
label: 'English',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
sidebar: [
|
|
29
|
+
{
|
|
30
|
+
label: 'Getting started',
|
|
31
|
+
items: [{ slug: 'guides/getting-started' }],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
customCss: ['./src/styles/custom.css'],
|
|
35
|
+
plugins: [<% if (includeBlog) { %>
|
|
36
|
+
starlightBlog({
|
|
37
|
+
authors: {
|
|
38
|
+
default: {
|
|
39
|
+
name: 'Docs Author',
|
|
40
|
+
title: 'Maintainer',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
<% } %>],
|
|
45
|
+
}),
|
|
46
|
+
],
|
|
47
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { getRelativeLocaleUrl } from 'astro:i18n';
|
|
3
|
+
import { LinkButton } from '@astrojs/starlight/components';
|
|
4
|
+
|
|
5
|
+
// Resolve an internal docs path against the current locale so a single source of
|
|
6
|
+
// truth (the `path` prop) produces a correct URL in every language. Callers pass
|
|
7
|
+
// a locale-agnostic path like `guides/getting-started`.
|
|
8
|
+
const { path, type } = Astro.props;
|
|
9
|
+
let resolvedPath = getRelativeLocaleUrl(Astro.currentLocale || 'en', path);
|
|
10
|
+
if (resolvedPath.endsWith('/')) {
|
|
11
|
+
resolvedPath = resolvedPath.slice(0, -1);
|
|
12
|
+
}
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
{
|
|
16
|
+
type === 'button' ? (
|
|
17
|
+
<LinkButton href={resolvedPath}>
|
|
18
|
+
<slot />
|
|
19
|
+
</LinkButton>
|
|
20
|
+
) : (
|
|
21
|
+
<a href={resolvedPath}>
|
|
22
|
+
<slot />
|
|
23
|
+
</a>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { Aside } from '@astrojs/starlight/components';
|
|
3
|
+
|
|
4
|
+
const locale = Astro.currentLocale || 'en';
|
|
5
|
+
const snippets = Object.values(
|
|
6
|
+
import.meta.glob('../content/docs/*/snippets/**/*.mdx', { eager: true })
|
|
7
|
+
);
|
|
8
|
+
const { name } = Astro.props;
|
|
9
|
+
const snippet = snippets.find((s) =>
|
|
10
|
+
s.file.endsWith(`content/docs/${locale}/snippets/${name}.mdx`)
|
|
11
|
+
);
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
{
|
|
15
|
+
snippet ? (
|
|
16
|
+
<snippet.Content />
|
|
17
|
+
) : (
|
|
18
|
+
<Aside type="danger">Unable to load snippet {name} for locale {locale}</Aside>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Welcome to <%= title %>
|
|
3
|
+
date: <%= today %>
|
|
4
|
+
authors:
|
|
5
|
+
- default
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Welcome to the **<%= title %>** blog! This post was scaffolded by the
|
|
9
|
+
`ts#astro-docs` generator.
|
|
10
|
+
|
|
11
|
+
The blog is powered by the [`starlight-blog`](https://starlight-blog-docs.vercel.app/)
|
|
12
|
+
plugin. Add new entries as MDX files under `src/content/docs/<locale>/blog/` with
|
|
13
|
+
`title`, `date` and `authors` frontmatter.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Getting started
|
|
3
|
+
description: Running your new Astro + Starlight docs site.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import Link from '@components/link.astro';
|
|
7
|
+
import Snippet from '@components/snippet.astro';
|
|
8
|
+
|
|
9
|
+
Welcome to **<%= title %>**! This site is built with [Astro](https://astro.build/) and the
|
|
10
|
+
[Starlight](https://starlight.astro.build/) documentation theme.
|
|
11
|
+
|
|
12
|
+
## Run locally
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
<%= pkgMgrCmd %> nx start <%= fullyQualifiedName %>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Build for production
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
<%= pkgMgrCmd %> nx build <%= fullyQualifiedName %>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Adding a locale
|
|
25
|
+
|
|
26
|
+
Add an entry to the `locales` block in `astro.config.mjs` and create a matching
|
|
27
|
+
directory under `src/content/docs/<locale>/`. Starlight will pick up the new locale
|
|
28
|
+
automatically.
|
|
29
|
+
<% if (includeTranslation) { %>
|
|
30
|
+
:::note[Keep the translation config in sync]
|
|
31
|
+
When you add a new locale, also add its code to `targetLanguages` in
|
|
32
|
+
`scripts/translate.config.json` so the `translate` task will keep it up to date.
|
|
33
|
+
:::
|
|
34
|
+
<% } %>
|
|
35
|
+
## Locale-aware links
|
|
36
|
+
|
|
37
|
+
Use the generated `Link` component whenever you want to link to another page
|
|
38
|
+
**inside** your docs — it automatically resolves the current locale, so a single
|
|
39
|
+
source of truth produces the right URL in every language:
|
|
40
|
+
|
|
41
|
+
```mdx
|
|
42
|
+
import Link from '@components/link.astro';
|
|
43
|
+
|
|
44
|
+
<Link path="guides/getting-started">Read the getting-started guide</Link>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Here is the component in action: <Link path="guides/getting-started">back to this page</Link>.
|
|
48
|
+
|
|
49
|
+
For regular external links, just use ordinary Markdown `[label](url)`.
|
|
50
|
+
|
|
51
|
+
## Using snippets
|
|
52
|
+
|
|
53
|
+
Snippets are reusable fragments of MDX stored in `src/content/docs/<locale>/snippets/`.
|
|
54
|
+
Include one in any page with the `Snippet` component:
|
|
55
|
+
|
|
56
|
+
```mdx
|
|
57
|
+
import Snippet from '@components/snippet.astro';
|
|
58
|
+
|
|
59
|
+
<Snippet name="example" />
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Here is the example snippet rendered inline:
|
|
63
|
+
|
|
64
|
+
<Snippet name="example" />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: <%= title %>
|
|
3
|
+
description: Documentation for <%= title %>.
|
|
4
|
+
template: splash
|
|
5
|
+
hero:
|
|
6
|
+
title: <%= title %>
|
|
7
|
+
tagline: Project documentation built with Astro and Starlight.
|
|
8
|
+
actions:
|
|
9
|
+
- text: Get started
|
|
10
|
+
link: /en/guides/getting-started
|
|
11
|
+
icon: right-arrow
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
import { CardGrid, Card } from '@astrojs/starlight/components';
|
|
15
|
+
|
|
16
|
+
<CardGrid>
|
|
17
|
+
<Card title="Guides" icon="open-book">
|
|
18
|
+
Reference documentation for <%= title %>.
|
|
19
|
+
</Card>
|
|
20
|
+
<Card title="Blog" icon="pencil">
|
|
21
|
+
News and updates from the team.
|
|
22
|
+
</Card>
|
|
23
|
+
<Card title="Snippets" icon="seti:config">
|
|
24
|
+
Reusable content fragments used across the docs.
|
|
25
|
+
</Card>
|
|
26
|
+
<Card title="Localised" icon="translate">
|
|
27
|
+
Localisation is configured out of the box — add target locales in `astro.config.mjs`.
|
|
28
|
+
</Card>
|
|
29
|
+
</CardGrid>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineCollection } from 'astro:content';
|
|
2
|
+
import { docsLoader } from '@astrojs/starlight/loaders';
|
|
3
|
+
import { docsSchema } from '@astrojs/starlight/schema';
|
|
4
|
+
import { blogSchema } from 'starlight-blog/schema';
|
|
5
|
+
|
|
6
|
+
export const collections = {
|
|
7
|
+
docs: defineCollection({
|
|
8
|
+
loader: docsLoader(),
|
|
9
|
+
schema: docsSchema({
|
|
10
|
+
extend: (context) => blogSchema(context),
|
|
11
|
+
}),
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* Customise the appearance of the Starlight docs theme here. */
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "astro/tsconfigs/strict",
|
|
3
|
+
"include": [".astro/types.d.ts", "**/*"],
|
|
4
|
+
"exclude": ["dist"],
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"baseUrl": ".",
|
|
7
|
+
"paths": {
|
|
8
|
+
"@components/*": ["src/components/*"],
|
|
9
|
+
"@assets/*": ["src/content/docs/assets/*"]
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|