You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Make Astro.request RFC changes (#270)
* Server-side rendering docs (#255)
This documents how to setup and use SSR features in Astro.
* Fix branch
* Update API Reference (#291)
* update API reference
* Update Astro.slots reference
* Update Astro.request and Astro.canonicalURL
* remove Astro.resolve section
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
* chore: update configuring Astro guide
* New config documentation (#293)
* Changed all astro.config references to .mjs (#283)
* Changed all config references to mjs
* removed changes here since auto generated
* Update src/pages/en/guides/configuring-astro.md
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
* import[dot]meta[dot]env (#286)
* new config
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
* update migration guide
* Update config.ts
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Co-authored-by: Nate Moore <nate@skypack.dev>
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
# NOTE: This file is auto-generated from 'scripts/docgen.mjs'
@@ -15,7 +15,7 @@ setup: |
15
15
import Since from '../../../components/Since.astro';
16
16
---
17
17
18
-
The following reference covers all supported configuration options in Astro. To learn more configuring Astro, read our guide on [Configuring Astro](/en/guides/configuring-astro/).
18
+
The following reference covers all supported configuration options in Astro. To learn more about configuring Astro, read our guide on [Configuring Astro](/en/guides/configuring-astro/).
Copy file name to clipboardExpand all lines: src/pages/de/core-concepts/routing.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,14 +40,14 @@ Angenommen du hast eine Seite `pages/post/[pid].astro`:
40
40
```astro
41
41
---
42
42
// Beispiel: src/pages/post/[pid].astro
43
-
const {pid} = Astro.request.params;
43
+
const {pid} = Astro.params;
44
44
---
45
45
<p>Post: {pid}</p>
46
46
```
47
47
48
-
Allen Routen mit z. B. `/post/1`, `/post/abc` etc. werden `pages/post/[pid].astro` entsprechen. Jeder passende Pfad-Parameter wird an die Page-Komponente unter `Astro.request.params` weitergegeben.
48
+
Allen Routen mit z. B. `/post/1`, `/post/abc` etc. werden `pages/post/[pid].astro` entsprechen. Jeder passende Pfad-Parameter wird an die Page-Komponente unter `Astro.params` weitergegeben.
49
49
50
-
Zum Beispiel wird die Route `/post/abc` das folgende `Astro.request.params`-Objekt zur Verfügung halten:
50
+
Zum Beispiel wird die Route `/post/abc` das folgende `Astro.params`-Objekt zur Verfügung halten:
Copy file name to clipboardExpand all lines: src/pages/en/guides/configuring-astro.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,12 +74,12 @@ You can also provide type definitions manually to VSCode, using this JSDoc notat
74
74
75
75
## Referencing Relative Files
76
76
77
-
If you provide a relative path to `projectRoot` or the `--project-root` CLI flag, Astro will resolve it against the current working directory where you ran the `astro` CLI command.
77
+
If you provide a relative path to `root` or the `--root` CLI flag, Astro will resolve it against the current working directory where you ran the `astro` CLI command.
78
78
79
79
```js
80
80
exportdefaultdefineConfig({
81
81
// Resolves to the "./foo" directory in your current working directory
82
-
projectRoot:'foo'
82
+
root:'foo'
83
83
})
84
84
```
85
85
@@ -88,9 +88,9 @@ Astro will resolve all other relative file and directory strings as relative to
88
88
```js
89
89
exportdefaultdefineConfig({
90
90
// Resolves to the "./foo" directory in your current working directory
91
-
projectRoot:'foo',
91
+
root:'foo',
92
92
// Resolves to the "./foo/public" directory in your current working directory
93
-
public:'public',
93
+
publicDir:'public',
94
94
})
95
95
```
96
96
@@ -99,9 +99,9 @@ To references a file or directory relative to the configuration file, use `impor
99
99
```js
100
100
exportdefaultdefineConfig({
101
101
// Resolves to the "./foo" directory, relative to this config file
102
-
projectRoot:newURL("./foo", import.meta.url),
102
+
root:newURL("./foo", import.meta.url),
103
103
// Resolves to the "./public" directory, relative to this config file
In this example we will use `@astrojs/netlify` to build for Netlify. First install the adapter:
22
+
23
+
```bash
24
+
npm install --save-dev @astrojs/netlify
25
+
```
26
+
27
+
Once your packages have been installed, add two new lines to your `astro.config.mjs` project configuration file.
28
+
29
+
```diff
30
+
// astro.config.mjs
31
+
import { defineConfig } from 'astro/config';
32
+
+ import netlify from '@astrojs/netlify/functions';
33
+
34
+
export default defineConfig({
35
+
+ adapter: netlify(),
36
+
});
37
+
```
38
+
39
+
With Netlify you can deploy from git, their web UI, or from the cli. Here we'll use the [Netlify CLI](https://docs.netlify.com/cli/get-started/) to deploy.
40
+
41
+
First build your site as normal:
42
+
43
+
```bash
44
+
npm run build
45
+
```
46
+
47
+
This creates `netlify/functions/` which contains your SSR code. Deploying your site will deploy this function which contains all of your Astro pages ready to be rendered.
48
+
49
+
```bash
50
+
netlify deploy
51
+
```
52
+
53
+
After the deploy is complete it should provide you a preview URL to see your site.
54
+
55
+
## Features
56
+
57
+
Astro will remain a static-site generator by default, but once you enable a server-side rendering adapter a few new features become available to you.
58
+
59
+
### Astro.request.headers
60
+
61
+
The headers for the request are available on `Astro.request.headers`. It is a [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) object, a Map-like object where you can retrieve headers such as the cookie.
On the `Astro` global, this method allows you to redirect to another page. You might do this after checking if the user is logged in by getting their session from a cookie.
// if the user is not logged in, redirect them to the login page.
84
+
if(!isLoggedIn(cookie)) {
85
+
return Astro.redirect('/login');
86
+
}
87
+
---
88
+
<html>
89
+
<!-- Page here... -->
90
+
</html>
91
+
```
92
+
93
+
### Response
94
+
95
+
You can also return a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) from any page. You might do this to return a 404 on a dynamic page after looking up an id in the database.
Copy file name to clipboardExpand all lines: src/pages/en/migrate.md
+75Lines changed: 75 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,81 @@ This guide exists to help you migrate to the latest versions of Astro and keep y
8
8
9
9
While we try to keep breaking changes to a minimum, we still expect some breaking changes before we hit a v1.0 release. Read the guide below for major highlights and instructions on updating breaking changes.
10
10
11
+
## Migrate to v0.26
12
+
### New Configuration API
13
+
14
+
Our Configuration API has been redesigned to solve a few glaring points of confusion that had built up over the last year. Most configuration has just been moved or renamed, which will hopefully be a quick update for most users. A few options have been refactored more heavily, and may require a few additional changes:
15
+
16
+
-`.buildOptions.site` has been replaced with `.site` (your deployed domain) and a new `.base` (your deployed subpath) option.
17
+
-`.markdownOptions` has been replaced with `.markdown`, a mostly similar config object with some small changes to simplify Markdown configuration.
18
+
-`.sitemap` has been moved into the [@astrojs/sitemap](https://www.npmjs.com/package/@astrojs/sitemap) integration.
19
+
20
+
If you run Astro with legacy configuration, you will see a warning with instructions on how to update. See our updated [Configuration Reference](/en/reference/configuration-reference/) for more information on upgrading.
21
+
22
+
Read [RFC0019](https://github.com/withastro/rfcs/blob/main/proposals/0019-config-finalization.md) for more background on these changes.
23
+
24
+
### New Markdown API
25
+
26
+
Astro v0.26 releases a brand new Markdown API for your content. This included three major user-facing changes:
27
+
- You can now `import`/`import()` markdown content directly using an ESM import.
28
+
- A new `Astro.glob()` API, for easier glob imports (especially for Markdown).
29
+
-**BREAKING CHANGE:**`Astro.fetchContent()` has been removed and replaced by `Astro.glob()`
30
+
-**BREAKING CHANGE:** Markdown objects have an updated interface.
31
+
32
+
```diff
33
+
// v0.25
34
+
- let allPosts = Astro.fetchContent('./posts/*.md');
35
+
// v0.26+
36
+
+ let allPosts = await Astro.glob('./posts/*.md');
37
+
```
38
+
39
+
When migrating, be careful about the new Markdown object interface. Frontmatter, for example, has been moved to the `.frontmatter` property, so references like `post.title` should change to `post.frontmatter.title`.
40
+
41
+
This should solve many issues for Markdown users, including some nice performance boosts for larger sites.
42
+
43
+
Read [RFC0017](https://github.com/withastro/rfcs/blob/main/proposals/0017-markdown-content-redesign.md) for more background on these changes.
44
+
45
+
### New Default Script Behavior
46
+
47
+
`<script>` tags in Astro components are now built, bundled and optimized by default. This completes a long-term move to make our Astro component syntax more consistent, matching the default-optimized behavior our `<style>` tags have today.
48
+
49
+
This includes a few changes to be aware of:
50
+
51
+
-**BREAKING:**`<script hoist>` is the new default `<script>` behavior. The `hoist` attribute has been removed.
52
+
- New `<script is:inline>` directive, to revert a `<script>` tag to previous default behavior (unbuilt, unbundled, untouched by Astro).
53
+
- New `<style is:inline>` directive, to leave a style tag inline in the page template (similar to previous `<script>` behavior).
54
+
- New `<style is:global>` directive to replace `<style global>` in a future release.
55
+
56
+
57
+
```diff
58
+
// v0.25
59
+
- <script hoist>
60
+
// v0.26+
61
+
+ <script>
62
+
```
63
+
64
+
Read [RFC0016](https://github.com/withastro/rfcs/blob/main/proposals/0016-style-script-defaults.md) for more background on these changes.
65
+
66
+
### Updated Astro.request API
67
+
68
+
69
+
`Astro.request` has been changed from our custom object to a standard `Request` object. This is part of a project to use more web standard APIs, especially where SSR is concerned.
70
+
71
+
This includes a few changes to be aware of:
72
+
73
+
- Change `Astro.request` to become a [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) object.
74
+
- Move `Astro.request.params` to `Astro.params`.
75
+
- Move `Astro.request.canonicalURL` to `Astro.canonicalURL`.
76
+
77
+
Read [RFC0018](https://github.com/withastro/rfcs/blob/main/proposals/0018-astro-request.md) for more background on these changes.
78
+
79
+
80
+
### Other Changes
81
+
82
+
- Improve `Astro.slots` API to support passing arguments to function-based slots. This allows for more ergonomic utility components that accept a callback function as a child.
83
+
- Update CLI output formatting, especially around error reporting.
84
+
- Update `@astrojs/compiler`, fixing some bugs related to RegExp usage in frontmatter
0 commit comments