Skip to content

Commit

Permalink
ci: update reference docs (#3426)
Browse files Browse the repository at this point in the history
Co-authored-by: delucis <delucis@users.noreply.github.com>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
3 people authored Jun 6, 2023
1 parent 9b641f0 commit 527bd31
Showing 1 changed file with 101 additions and 91 deletions.
192 changes: 101 additions & 91 deletions src/content/docs/en/reference/configuration-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,53 @@ The value can be either an absolute file system path or a path relative to the p
```


### redirects (Experimental)

<p>

**Type:** `RedirectConfig`<br />
**Default:** `{}`<br />
<Since v="2.6.0" />
</p>

Specify a mapping of redirects where the key is the route to match
and the value is the path to redirect to.

You can redirect both static and dynamic routes, but only to the same kind of route.
For example you cannot have a `'/article': '/blog/[...slug]'` redirect.


```js
{
redirects: {
'/old': '/new',
'/blog/[...slug]': '/articles/[...slug]',
}
}
```


For statically-generated sites with no adapter installed, this will produce a client redirect using a [`<meta http-equiv="refresh">` tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#http-equiv) and does not support status codes.

When using SSR or with a static adapter in `output: static`
mode, status codes are supported.
Astro will serve redirected GET requests with a status of `301`
and use a status of `308` for any other request method.

You can customize the [redirection status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages) using an object in the redirect config:

```js
{
redirects: {
'/other': {
status: 302,
destination: '/place',
},
}
}
```


### site

<p>
Expand Down Expand Up @@ -425,6 +472,54 @@ detects that the file is a JavaScript module.
```


### build.redirects

<p>

**Type:** `boolean`<br />
**Default:** `true`<br />
<Since v="2.6.0" />
</p>

Specifies whether redirects will be output to HTML during the build.
This option only applies to `output: 'static'` mode; in SSR redirects
are treated the same as all responses.

This option is mostly meant to be used by adapters that have special
configuration files for redirects and do not need/want HTML based redirects.

```js
{
build: {
redirects: false
}
}
```


### build.inlineStylesheets

<p>

**Type:** `'always' | 'auto' | 'never'`<br />
**Default:** `never`<br />
<Since v="2.6.0" />
</p>

Control whether styles are sent to the browser in a separate css file or inlined into `<style>` tags. Choose from the following options:
- `'always'` - all styles are inlined into `<style>` tags
- `'auto'` - only stylesheets smaller than `ViteConfig.build.assetsInlineLimit` (default: 4kb) are inlined. Otherwise, styles are sent in external stylesheets.
- `'never'` - all styles are sent in external stylesheets

```js
{
build: {
inlineStylesheets: `auto`,
},
}
```


## Server Options

Customize the Astro dev server, used by both `astro dev` and `astro preview`.
Expand Down Expand Up @@ -747,110 +842,25 @@ To enable this feature, set `experimental.assets` to `true` in your Astro config
```


### experimental.inlineStylesheets

<p>

**Type:** `'always' | 'auto' | 'never'`<br />
**Default:** `never`<br />
<Since v="2.4.0" />
</p>

Control whether styles are sent to the browser in a separate css file or inlined into `<style>` tags. Choose from the following options:
- `'always'` - all styles are inlined into `<style>` tags
- `'auto'` - only stylesheets smaller than `ViteConfig.build.assetsInlineLimit` (default: 4kb) are inlined. Otherwise, styles are sent in external stylesheets.
- `'never'` - all styles are sent in external stylesheets

```js
{
experimental: {
inlineStylesheets: `auto`,
},
}
```


### experimental.customClientDirectives

<p>

**Type:** `boolean`<br />
**Default:** `false`<br />
<Since v="2.5.0" />
</p>

Allow integrations to use the [experimental `addClientDirective` API](/en/reference/integrations-reference/#addclientdirective-option) in the `astro:config:setup` hook
to add custom client directives in Astro files.

To enable this feature, set `experimental.customClientDirectives` to `true` in your Astro config:

```js
{
experimental: {
customClientDirectives: true,
},
}
```


### experimental.middleware
### experimental.redirects

<p>

**Type:** `boolean`<br />
**Default:** `false`<br />
<Since v="2.4.0" />
<Since v="2.6.0" />
</p>

Enable experimental support for Astro middleware.

To enable this feature, set `experimental.middleware` to `true` in your Astro config:
Enable experimental support for redirect configuration. With this enabled
you can set redirects via the top-level `redirects` property. To enable
this feature, set `experimental.redirects` to `true`.

```js
{
experimental: {
middleware: true,
redirects: true,
},
}
```


### experimental.hybridOutput

<p>

**Type:** `boolean`<br />
**Default:** `false`<br />
<Since v="2.5.0" />
</p>

Enable experimental support for hybrid SSR with pre-rendering enabled by default.

To enable this feature, first set `experimental.hybridOutput` to `true` in your Astro config, and set `output` to `hybrid`.

```js
{
output: 'hybrid',
experimental: {
hybridOutput: true,
},
}
```
Then add `export const prerender = false` to any page or endpoint you want to opt-out of pre-rendering.
```astro
---
// pages/contact.astro
export const prerender = false
if (Astro.request.method === 'POST') {
// handle form submission
}
---
<form method="POST">
<input type="text" name="name" />
<input type="email" name="email" />
<button type="submit">Submit</button>
</form>
```


0 comments on commit 527bd31

Please sign in to comment.