Skip to content

Commit 284f129

Browse files
authored
Merge branch 'main' into i18n/fr-update-guides/astro-db.mdx
2 parents 576dbc1 + 50d2df5 commit 284f129

File tree

10 files changed

+288
-12
lines changed

10 files changed

+288
-12
lines changed

src/content/docs/en/guides/content-collections.mdx

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,73 @@ const { Content } = await render(post);
569569
Explore the `src/pages/` folder of the [blog tutorial demo code on GitHub](https://github.com/withastro/blog-tutorial-demo/tree/content-collections/src/pages) to see full examples of creating pages from your collections for blog features like a list of blog posts, tags pages, and more!
570570
:::
571571

572+
## Collection JSON Schemas
573+
574+
<p><Since v="4.13.0" /></p>
575+
576+
Astro auto-generates [JSON Schema](https://json-schema.org/) files for collections, which you can use in your editor to get IntelliSense and type-checking for data files.
577+
578+
A JSON Schema file is generated for each collection in your project and output to the `.astro/collections/` directory.
579+
For example, if you have two collections, one named `authors` and another named `posts`, Astro will generate `.astro/collections/authors.schema.json` and `.astro/collections/posts.schema.json`.
580+
581+
### Use JSON Schemas in JSON files
582+
583+
You can manually point to an Astro-generated schema by setting the `$schema` field in your JSON file.
584+
The value should be a relative file path from the data file to the schema.
585+
In the following example, a data file in `src/data/authors/` uses the schema generated for the `authors` collection:
586+
587+
```json title="src/data/authors/armand.json" ins={2}
588+
{
589+
"$schema": "../../../.astro/collections/authors.schema.json",
590+
"name": "Armand",
591+
"skills": ["Astro", "Starlight"]
592+
}
593+
```
594+
595+
#### Use a schema for a group of JSON files in VS Code
596+
597+
In VS Code, you can configure a schema to apply for all files in a collection using the [`json.schemas` setting](https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings).
598+
In the following example, all files in the `src/data/authors/` directory will use the schema generated for the `authors` collection:
599+
600+
```json
601+
{
602+
"json.schemas": [
603+
{
604+
"fileMatch": ["/src/data/authors/**"],
605+
"url": "./.astro/collections/authors.schema.json"
606+
}
607+
]
608+
}
609+
```
610+
611+
### Use schemas in YAML files in VS Code
612+
613+
In VS Code, you can add support for using JSON schemas in YAML files using the [Red Hat YAML](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) extension.
614+
With this extension installed, you can reference a schema in a YAML file using a special comment syntax:
615+
616+
```yaml title="src/data/authors/armand.yml" ins={1}
617+
# yaml-language-server: $schema=../../../.astro/collections/authors.schema.json
618+
name: Armand
619+
skills:
620+
- Astro
621+
- Starlight
622+
```
623+
624+
#### Use schemas for a group of YAML files in VS Code
625+
626+
With the Red Hat YAML extension, you can configure a schema to apply for all YAML files in a collection using the `yaml.schemas` setting.
627+
In the following example, all YAML files in the `src/data/authors/` directory will use the schema generated for the `authors` collection:
628+
629+
```json
630+
{
631+
"yaml.schemas": {
632+
"./.astro/collections/authors.schema.json": ["/src/content/authors/*.yml"]
633+
}
634+
}
635+
```
636+
637+
See [“Associating schemas”](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml#associating-schemas) in the Red Hat YAML extension documentation for more details.
638+
572639
## When to create a collection
573640

574641
You can [create a collection](#defining-collections) any time you have a group of related data or content that shares a common structure.

src/content/docs/en/guides/deploy/railway.mdx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,51 @@ i18nReady: true
88
stub: true
99
---
1010

11+
import { Steps } from '@astrojs/starlight/components';
12+
1113
[Railway](https://railway.com) is a deployment platform built to simplify your infrastructure stack from servers to observability with a single, scalable platform.
1214

15+
This guide is for deploying an Astro static site to Railway using either the web interface or Railway CLI tool.
16+
17+
:::tip
18+
To deploy an Astro site with on-demand rendering (SSR) using the Node adapter, you can follow [Railway's guide to deploying an Astro site](https://docs.railway.com/guides/astro).
19+
:::
20+
21+
## Project Configuration
22+
23+
Railway's default build system, [Railpack](https://docs.railway.com/reference/railpack), automatically builds your Astro project as a static site.
24+
25+
## Deploy via the web interface
26+
27+
<Steps>
28+
1. Create a [Railway account](https://railway.com/dashboard) and sign in.
29+
30+
2. From the Railway dashboard, create a new [project](https://docs.railway.com/guides/projects).
31+
32+
3. Select the option to deploy from a GitHub repository, and select your Astro project.
33+
34+
4. Generate or add a custom domain from your project's [network settings](https://docs.railway.com/guides/public-networking#railway-provided-domain).
35+
</Steps>
36+
37+
## Deploy via Railway CLI
38+
39+
<Steps>
40+
1. [Install](https://docs.railway.com/guides/cli#installing-the-cli) the Railway CLI tool.
41+
42+
2. Login with the command `railway login`.
43+
44+
3. From within your Astro project, run `railway init` and choose a workspace and project name.
45+
46+
4. Run `railway up` to deploy your project on Railway.
47+
48+
5. Run `railway domain` to generate a Railway provided service domain.
49+
</Steps>
50+
51+
1352
## Official Resources
1453

1554
[Railway guide to deploying an Astro app](https://docs.railway.com/guides/astro)
1655

1756
## Community Resources
1857

19-
[How to host an Astro site on Railway](https://jacksmith.xyz/blog/how-to-host-astro-site-on-railway)
58+
[How to host an Astro site on Railway](https://jacksmith.xyz/blog/how-to-host-astro-site-on-railway)

src/content/docs/en/guides/integrations-guide/react.mdx

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ category: renderer
99
i18nReady: true
1010
---
1111
import PackageManagerTabs from '~/components/tabs/PackageManagerTabs.astro'
12+
import Since from '~/components/Since.astro';
1213

1314
This **[Astro integration][astro-integration]** enables rendering and client-side hydration for your [React](https://react.dev/) components.
1415

@@ -114,6 +115,79 @@ To use your first React component in Astro, head to our [UI framework documentat
114115
* 💧 client-side hydration options, and
115116
* 🤝 opportunities to mix and nest frameworks together
116117

118+
## Integrate Actions with `useActionState()` (experimental)
119+
120+
The `@astrojs/react` integration provides two experimental functions for use with [Astro Actions][astro-actions]: `experimental_withState()` and `experimental_getActionState()`.
121+
122+
These are used with [React's useActionState() hook](https://react.dev/reference/react/useActionState) to read and update client-side state when triggering actions during form submission.
123+
124+
### `experimental_withState()`
125+
126+
<p>
127+
128+
**Type:** `(action: FormFn<T>) => (state: T, formData: FormData) => FormFn<T>`<br />
129+
<Since v="4.3.2" />
130+
</p>
131+
132+
You can pass `experimental_withState()` and the action you want to trigger to React's `useActionState()` hook as the form action function. The example below passes a `like` action to increase a counter along with an initial state of `0` likes.
133+
134+
```jsx title="Like.tsx" ins={2,7} "useActionState"
135+
import { actions } from 'astro:actions';
136+
import { experimental_withState } from '@astrojs/react/actions';
137+
import { useActionState } from "react";
138+
139+
export function Like({ postId }: { postId: string }) {
140+
const [state, action, pending] = useActionState(
141+
experimental_withState(actions.like),
142+
{ data: 0, error: undefined }, // initial likes and errors
143+
);
144+
145+
return (
146+
<form action={action}>
147+
<input type="hidden" name="postId" value={postId} />
148+
<button disabled={pending}>{state.data} ❤️</button>
149+
</form>
150+
);
151+
}
152+
```
153+
154+
The `experimental_withState()` function will match the action's types with React's expectations and preserve metadata used for progressive enhancement, allowing it to work even when JavaScript is disabled on the user's device.
155+
156+
### `experimental_getActionState()`
157+
158+
<p>
159+
160+
**Type:** `(context: ActionAPIContext) => Promise<T>`<br />
161+
<Since v="4.3.2" />
162+
</p>
163+
164+
You can access the state stored by `useActionState()` on the server in your action `handler` with `experimental_getActionState()`. It accepts the [Astro API context](/en/reference/api-reference/#the-context-object), and optionally, you can apply a type to the result.
165+
166+
The example below gets the current value of likes from a counter, typed as a number, in order to create an incrementing `like` action:
167+
168+
```ts title="actions.ts" ins={3,11}
169+
import { defineAction, type SafeResult } from 'astro:actions';
170+
import { z } from 'astro:schema';
171+
import { experimental_getActionState } from '@astrojs/react/actions';
172+
173+
export const server = {
174+
like: defineAction({
175+
input: z.object({
176+
postId: z.string(),
177+
}),
178+
handler: async ({ postId }, ctx) => {
179+
const { data: currentLikes = 0, error } = await experimental_getActionState<SafeResult<any, number>>(ctx);
180+
181+
// handle errors
182+
if (error) throw error;
183+
184+
// write to database
185+
return currentLikes + 1;
186+
},
187+
})
188+
};
189+
```
190+
117191
## Options
118192

119193
### Combining multiple JSX frameworks
@@ -201,11 +275,13 @@ export default defineConfig({
201275
integrations: [
202276
react({
203277
experimentalDisableStreaming: true,
204-
}),
205-
],
278+
})
279+
]
206280
});
207281
```
208282

209283
[astro-integration]: /en/guides/integrations-guide/
210284

211285
[astro-ui-frameworks]: /en/guides/framework-components/#using-framework-components
286+
287+
[astro-actions]: /en/guides/actions/

src/content/docs/es/basics/astro-pages.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Esto generará una página `404.html` que la mayoría de los [servicios de despl
104104

105105
## Página de error 500 personalizada
106106

107-
Para que una página de error 500 personalizada se muestre para las páginas que se [renderizan bajo demanda](/es/guides/on-demand-rendering/), crea el archivo `src/pages/500.astro`. Esta página personalizada no está disponible para las páginas prerenderizadas y no puede ser prerenderizada.
107+
Para que una página de error 500 personalizada se muestre para las páginas que se [renderizan bajo demanda](/es/guides/on-demand-rendering/), crea el archivo `src/pages/500.astro`. Esta página personalizada no está disponible para las páginas prerenderizadas.
108108

109109
Si se produce un error al renderizar esta página, se mostrará la página de error 500 predeterminada de tu host a tu visitante.
110110

src/content/docs/es/editor-setup.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Las instrucciones de instalación, integración del editor e información adicio
7777

7878
### Prettier
7979

80-
[Prettier](https://prettier.io/) es un formateador popular para JavaScript, HTML, CSS y más. Si estás usando la [extensión de VS Code de Astro](https://marketplace.visualstudio.com/items?itemName=astro-build.astro-vscode) o [el servidor de lenguaje de Astro dentro de otro editor](#otros-editores-de-código), el formateo de código con Prettier está incluido.
80+
[Prettier](https://prettier.io/) es un formateador popular para JavaScript, HTML, CSS y más. Si estás usando la [extensión de VS Code de Astro](https://marketplace.visualstudio.com/items?itemName=astro-build.astro-vscode), el formateo de código con Prettier está incluido.
8181

8282
Para dar soporte al formateo de archivos `.astro` fuera del editor (por ejemplo, CLI) o dentro de editores que no soportan nuestras herramientas de editor, instala [el plugin oficial de Prettier de Astro](https://github.com/withastro/prettier-plugin-astro).
8383

src/content/docs/fr/guides/authentication.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Auth.js est une solution d'authentification indépendante du framework. Un adapt
2525

2626
### Installation
2727

28-
Utilisez la commande `astro add` de votre gestionnaire de paquets préféré pour ajouter l'intégration `auth-astro`.
28+
Utilisez la commande `astro add` de votre gestionnaire de paquets préféré pour ajouter l'intégration `auth-astro` à un projet Astro configuré avec un [adaptateur de serveur](/fr/guides/on-demand-rendering/#adaptateurs-de-serveur) pour le rendu à la demande.
2929

3030
<PackageManagerTabs>
3131
<Fragment slot="npm">
@@ -69,12 +69,13 @@ Pour installer `auth-astro` manuellement, installez le paquet requis pour votre
6969

7070
Ensuite, appliquez l'intégration à votre fichier `astro.config.*` en utilisant la propriété `integrations` :
7171

72-
```ts title="astro.config.mjs" ins={2,6}
72+
```ts title="astro.config.mjs" ins={2,7}
7373
import { defineConfig } from 'astro/config';
7474
import auth from 'auth-astro';
7575

7676
export default defineConfig({
7777
// ...
78+
adapter: netlify(),
7879
integrations: [auth()],
7980
});
8081
```

src/content/docs/fr/guides/integrations-guide/sitemap.mdx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,38 @@ export default defineConfig({
516516

517517
La configuration donnée générera des fichiers de sitemap aux adresses `https://example.com/sitemap-astronomie-0.xml` et `https://example.com/sitemap-astronomie-index.xml`.
518518

519+
### `namespaces`
520+
521+
<p>
522+
523+
**Type :** `{ news?: boolean; xhtml?: boolean; image?: boolean; video?: boolean; }` <br />
524+
**Par défaut :** `{ news: true, xhtml: true, image: true, video: true }` <br />
525+
<Since v="3.6.0" pkg="@astrojs/sitemap" />
526+
</p>
527+
528+
Un objet d’espaces de noms XML à exclure du sitemap généré.
529+
530+
L'exclusion des espaces de noms inutilisés peut aider à créer des sitemaps plus ciblés, plus rapides à analyser par les moteurs de recherche et utilisant moins de bande passante. Par exemple, si votre site ne propose pas des actualités, des vidéos ou de contenu multilingue, vous pouvez exclure ces espaces de noms pour réduire la surcharge XML.
531+
532+
Par défaut, tous les espaces de noms configurables (`news`, `xhtml`, `image` et `video`) sont inclus dans le sitemap généré en XML. Pour exclure un ou plusieurs de ces espaces de noms de la génération de votre sitemap, ajoutez un objet de configuration `namespaces` et définissez les options individuelles sur `false`.
533+
534+
```js title="astro.config.mjs" ins={8-11}
535+
import { defineConfig } from 'astro/config';
536+
import sitemap from '@astrojs/sitemap';
537+
538+
export default defineConfig({
539+
site: 'https://example.com',
540+
integrations: [
541+
sitemap({
542+
namespaces: {
543+
news: false,
544+
xhtml: false,
545+
}
546+
})
547+
]
548+
});
549+
```
550+
519551
## Exemples
520552

521553
* Le site officiel d'Astro utilise Astro Sitemap pour générer [son plan du site](https://astro.build/sitemap-index.xml).

src/content/docs/ko/guides/astro-db.mdx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,6 @@ Astro DB를 사용하면 로컬 및 원격 데이터베이스에 모두 연결
232232

233233
호스팅된 원격 데이터베이스에 연결하려면 `--remote` 플래그를 사용합니다. 이 플래그를 사용하면 원격 데이터베이스에 대한 읽기 및 쓰기 액세스가 모두 가능하므로 프로덕션 환경에서 [사용자 데이터를 허용 및 유지](#insert)할 수 있습니다.
234234

235-
:::note
236-
일반적으로 정적 또는 서버 렌더링 모드를 사용하는 모든 배포 플랫폼에서 원격 연결이 가능하지만, 현재 몇 가지 제한 사항이 있습니다. Cloudflare 및 Deno와 같은 Node 기반이 아닌 런타임은 현재 libSQL을 사용할 때 서버 렌더링 경로에서 DB를 지원하지 않습니다. 이러한 플랫폼에 대한 지원은 향후 구현될 예정입니다.
237-
:::
238-
239235
`--remote` 플래그를 사용하도록 빌드 명령을 구성합니다:
240236

241237
```json title="package.json" "--remote"
@@ -260,7 +256,7 @@ astro dev --remote
260256
개발 모드에서 `--remote`를 사용할 때는 주의하세요. 이렇게 하면 라이브 프로덕션 데이터베이스에 연결되며 모든 변경 사항 (삽입, 업데이트, 삭제)이 유지됩니다.
261257
:::
262258

263-
`--remote` 플래그는 로컬 빌드와 서버에서 모두 원격 DB에 대한 연결을 사용합니다. 로컬 개발 환경과 배포 플랫폼 모두에서 필요한 환경 변수를 설정했는지 확인하세요.
259+
`--remote` 플래그는 로컬 빌드와 서버에서 모두 원격 DB에 대한 연결을 사용합니다. 로컬 개발 환경과 배포 플랫폼 모두에서 필요한 환경 변수를 설정했는지 확인하세요. 또한 Cloudflare Workers나 Deno와 같은 Node.js가 아닌 런타임 환경에서는 [웹 모드를 구성](/ko/guides/integrations-guide/db/#mode)해야 할 수도 있습니다.
264260

265261
Astro DB 프로젝트를 배포할 때, 배포 플랫폼의 빌드 명령이 `package.json`에 구성된 `--remote` 플래그를 활용하도록 `npm run build` (또는 패키지 관리자에 상응하는 명령어)로 설정되어 있는지 확인하세요.
266262

src/content/docs/ko/guides/integrations-guide/db.mdx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ i18nReady: true
1111
import { FileTree } from '@astrojs/starlight/components';
1212
import PackageManagerTabs from '~/components/tabs/PackageManagerTabs.astro';
1313
import ReadMore from '~/components/ReadMore.astro';
14+
import Since from '~/components/Since.astro';
1415

1516
Astro DB는 Astro 생태계를 위해 설계된 완전 관리형 SQL 데이터베이스입니다. Astro에서 로컬로 개발하고 모든 [libSQL 호환 데이터베이스](/ko/guides/astro-db/)에 배포하세요.
1617

@@ -92,6 +93,38 @@ export default defineDb({
9293
})
9394
```
9495

96+
## 구성
97+
98+
### `mode`
99+
100+
<p>
101+
102+
**타입:** `'node' | 'web'`<br />
103+
**기본값:** `'node'`<br />
104+
<Since v="0.18.0" pkg="@astrojs/db" />
105+
</p>
106+
107+
프로덕션 환경에서 데이터베이스에 연결할 때 사용할 드라이버를 구성합니다.
108+
109+
기본적으로 Astro DB는 프로덕션 배포에 Node.js 기반 libSQL 드라이버를 사용합니다. Node.js 런타임을 사용하는 대부분의 Astro 호스팅 또는 자체 호스팅 웹사이트에는 `node` 드라이버 모드로 충분합니다. 이를 통해 `memory:`, `file:`, `ws:`, `wss:`, `libsql`, `http`, `https` 등 여러 프로토콜을 통해 데이터베이스에 연결할 수 있으며, [임베디드 레플리카](/ko/guides/astro-db/#syncurl)와 같은 고급 기능도 사용할 수 있습니다.
110+
111+
Cloudflare Workers나 Deno와 같은 Node.js가 아닌 런타임의 서버리스 환경에 배포할 경우, 웹 기반 libSQL 드라이버를 사용할 수 있습니다. `web` 모드를 사용하여 배포할 경우, `libsql`, `http`, `https`를 통해 웹 기반 연결을 설정할 수 있습니다.
112+
113+
Node.js 환경이 아닌 경우 웹 libSQL 드라이버 모드를 사용하려면 어댑터 구성에서 `mode` 속성을 설정해야 합니다.
114+
115+
```ts title="astro.config.mjs" ins={7}
116+
import { defineConfig } from 'astro/config';
117+
import db from '@astrojs/db';
118+
119+
export default defineConfig({
120+
integrations: [
121+
db({
122+
mode: 'web'
123+
})
124+
]
125+
});
126+
```
127+
95128
## 테이블 구성 참조
96129

97130
### `columns`

0 commit comments

Comments
 (0)