Skip to content

Commit 675b57e

Browse files
authored
Merge branch 'main' into i18n/fr-update-api-reference.mdx
2 parents 4e4fbd1 + 8739fe1 commit 675b57e

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ You can query your database from any [Astro page](/en/basics/astro-pages/#astro-
162162

163163
### Drizzle ORM
164164

165-
```
165+
```ts
166166
import { db } from 'astro:db';
167167
```
168168

src/content/docs/en/reference/api-reference.mdx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,15 +2495,15 @@ Actions help you build a type-safe backend you can call from client code and HTM
24952495
<Since v="4.15.0" />
24962496
</p>
24972497

2498-
The `defineAction()` utility is used to define new actions from the `src/actions/index.ts` file. This accepts a `handler()` function containing the server logic to run, and an optional `input` property to validate input parameters at runtime.
2498+
The `defineAction()` utility is used to define new actions from the `src/actions/index.ts` file. This accepts a [`handler()`](#handler-property) function containing the server logic to run, and an optional [`input`](#input-validator) property to validate input parameters at runtime.
24992499

25002500
```ts
25012501
export const server = {
2502-
getGreeting: defineAction({
2502+
getGreeting: defineAction({
25032503
input: z.object({
25042504
name: z.string(),
25052505
}),
2506-
handler: async (input) => {
2506+
handler: async (input, context) => {
25072507
return `Hello, ${input.name}!`
25082508
}
25092509
})
@@ -2513,17 +2513,21 @@ export const server = {
25132513
#### `handler()` property
25142514

25152515
<p>
2516-
<Since v="4.15.0" />
2516+
2517+
**Type:** `(input, context) => any`
25172518
</p>
25182519

2519-
`defineAction()` accepts a `handler()` function containing the server logic to run when the action is called. This function can return data that is automatically serialized and sent to the caller.
2520+
`defineAction()` requires a `handler()` function containing the server logic to run when the action is called. Data returned from the handler is automatically serialized and sent to the caller.
2521+
2522+
The `handler()` is called with user input as its first argument. If an [`input`](#input-validator) validator is set, the user input will be validated before being passed to the handler. The second argument is a `context` object containing most of Astro’s [standard endpoint context](#endpoint-context), excluding `getActionResult()`, `callAction()`, and `redirect()`.
25202523

2521-
Return values are parsed using the [devalue library](https://github.com/Rich-Harris/devalue). This supports JSON values, along with instances of `Date()`, `Map()`, `Set()`, or `URL()`.
2524+
Return values are parsed using the [devalue library](https://github.com/Rich-Harris/devalue). This supports JSON values and instances of `Date()`, `Map()`, `Set()`, and `URL()`.
25222525

25232526
#### `input` validator
25242527

25252528
<p>
2526-
<Since v="4.15.0" />
2529+
2530+
**Type:** `ZodObject | undefined`
25272531
</p>
25282532

25292533
The optional `input` property accepts a Zod validator to validate handler inputs at runtime. If the action fails to validate, [a `BAD_REQUEST` error](#actionerror) is returned and the `handler` is not called.

src/content/docs/en/reference/configuration-reference.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ By default, Astro's i18n routing creates pages that redirect your visitors to a
12041204

12051205
When `i18n.routing.fallback: "rewrite"` is configured, Astro will create pages that render the contents of the fallback page on the original, requested URL.
12061206

1207-
With the following configuration, if you have the file `src/pages/en/about.astro` but not `src/pages/fr/about.astro`, the `astro build` command will generate `dist/fr/about.html` with the same content as the `dist/en/index.html` page.
1207+
With the following configuration, if you have the file `src/pages/en/about.astro` but not `src/pages/fr/about.astro`, the `astro build` command will generate `dist/fr/about.html` with the same content as the `dist/en/about.html` page.
12081208
Your site visitor will see the English version of the page at `https://example.com/fr/about/` and will not be redirected.
12091209

12101210
```js

0 commit comments

Comments
 (0)