Skip to content

Commit 9e3c8ab

Browse files
committed
Merge branch 'master' into playwright
2 parents e39a1eb + 385b1a5 commit 9e3c8ab

File tree

35 files changed

+177
-103
lines changed

35 files changed

+177
-103
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
create `__data.json` for pathnames with trailing slashes, including `/`

.changeset/eight-chicken-sin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
Disable meta http-equiv tags for static amp configuration

.changeset/four-ties-destroy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/adapter-auto': patch
3+
---
4+
5+
Attempt to bump @next version of adapter-auto

.changeset/great-seahorses-fry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'create-svelte': patch
3+
---
4+
5+
fix `@typescript-eslint/no-empty-interface` lint error when starting a new app with eslint

.changeset/pre.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"@sveltejs/app-utils": "0.0.18",
1111
"create-svelte": "2.0.0-alpha.19",
1212
"@sveltejs/kit": "0.0.30",
13-
"@sveltejs/vite-plugin-svelte": "1.0.0-next.0",
13+
"@sveltejs/vite-plugin-svelte": "0.0.1",
1414
"@sveltejs/adapter-cloudflare-workers": "0.0.1",
15-
"@sveltejs/adapter-cloudflare": "1.0.0-next.0",
16-
"@sveltejs/adapter-auto": "1.0.0-next",
15+
"@sveltejs/adapter-cloudflare": "0.0.1",
16+
"@sveltejs/adapter-auto": "0.0.1",
1717
"set-env-action": "1.0.0",
1818
"~TODO~": "0.0.1",
1919
"prerendering-test-basics": "0.0.1",
@@ -51,6 +51,7 @@
5151
"brave-turkeys-bathe",
5252
"brave-weeks-allow",
5353
"breezy-games-count",
54+
"breezy-onions-remember",
5455
"breezy-sheep-dress",
5556
"breezy-students-refuse",
5657
"bright-cherries-hug",
@@ -141,6 +142,7 @@
141142
"early-snakes-peel",
142143
"early-wasps-obey",
143144
"eight-birds-run",
145+
"eight-chicken-sin",
144146
"eight-glasses-sparkle",
145147
"eight-hats-worry",
146148
"eight-keys-give",
@@ -197,6 +199,7 @@
197199
"four-cheetahs-yawn",
198200
"four-news-turn",
199201
"four-pillows-give",
202+
"four-ties-destroy",
200203
"fresh-adults-ring",
201204
"fresh-dolls-destroy",
202205
"fresh-hats-tie",
@@ -240,6 +243,7 @@
240243
"great-guests-visit",
241244
"great-kangaroos-eat",
242245
"great-queens-rule",
246+
"great-seahorses-fry",
243247
"green-mayflies-shave",
244248
"green-spoons-count",
245249
"grumpy-days-compete",
@@ -687,6 +691,7 @@
687691
"tidy-pigs-peel",
688692
"tidy-turkeys-rule",
689693
"tidy-wasps-shave",
694+
"tiny-badgers-love",
690695
"tiny-candles-repeat",
691696
"tiny-files-smile",
692697
"tiny-gorillas-whisper",
@@ -714,6 +719,7 @@
714719
"twelve-feet-deny",
715720
"twelve-goats-knock",
716721
"twelve-onions-burn",
722+
"twenty-dogs-shout",
717723
"twenty-dryers-hope",
718724
"twenty-hairs-shave",
719725
"twenty-numbers-destroy",

.changeset/tiny-badgers-love.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
Ignore click event if url does not have origin (e.g. `mailto:`, `tel:`)

.changeset/twenty-dogs-shout.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@sveltejs/adapter-auto': patch
3+
'@sveltejs/adapter-cloudflare': patch
4+
---
5+
6+
Attempt to force @next version bump

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v2
17-
- uses: pnpm/action-setup@v2.1.0
17+
- uses: pnpm/action-setup@v2.2.0
1818
with:
1919
version: 6.23.2
2020
- uses: actions/setup-node@v2
@@ -39,7 +39,7 @@ jobs:
3939
steps:
4040
- run: git config --global core.autocrlf false
4141
- uses: actions/checkout@v2
42-
- uses: pnpm/action-setup@v2.1.0
42+
- uses: pnpm/action-setup@v2.2.0
4343
with:
4444
version: 6.23.2
4545
- uses: actions/setup-node@v2

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
1919
fetch-depth: 0
20-
- uses: pnpm/action-setup@v2.1.0
20+
- uses: pnpm/action-setup@v2.2.0
2121
with:
2222
version: 6.23.2
2323
- name: Setup Node.js

documentation/docs/01-routing.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ A file or directory can have multiple dynamic parts, like `[id]-[category].svelt
4545

4646
### Endpoints
4747

48-
Endpoints are modules written in `.js` (or `.ts`) files that export functions corresponding to HTTP methods. Their job is to allow pages to read and write data that is only available on the server (for example in a database, or on the filesystem).
49-
50-
If an endpoint has the same filename as a page (except for the extension), the page will get its props from the endpoint. So a page like `src/routes/items/[id].svelte` could get its props from this file:
48+
Endpoints are modules written in `.js` (or `.ts`) files that export [request handler](/docs/types#sveltejs-kit-requesthandler) functions corresponding to HTTP methods. Their job is to make it possible to read and write data that is only available on the server (for example in a database, or on the filesystem).
5149

5250
```js
5351
/// file: src/routes/items/[id].js
@@ -81,7 +79,7 @@ export async function get({ params }) {
8179

8280
> All server-side code, including endpoints, has access to `fetch` in case you need to request data from external APIs. Don't worry about the `$lib` import, we'll get to that [later](/docs/modules#$lib).
8381
84-
The job of this function is to return a `{ status, headers, body }` object representing the response, where `status` is an [HTTP status code](https://httpstatusdogs.com):
82+
The job of a [request handler](/docs/types#sveltejs-kit-requesthandler) is to return a `{ status, headers, body }` object representing the response, where `status` is an [HTTP status code](https://httpstatusdogs.com):
8583

8684
- `2xx` — successful response (default is `200`)
8785
- `3xx` — redirection (should be accompanied by a `location` header)
@@ -90,7 +88,11 @@ The job of this function is to return a `{ status, headers, body }` object repre
9088

9189
> If `{fallthrough: true}` is returned SvelteKit will [fall through](/docs/routing#advanced-routing-fallthrough-routes) to other routes until something responds, or will respond with a generic 404.
9290
93-
The returned `body` corresponds to the page's props:
91+
#### Page endpoints
92+
93+
If an endpoint has the same filename as a page (except for the extension), the page gets its props from the endpoint — via `fetch` during client-side navigation, or via direct function call during SSR.
94+
95+
A page like `src/routes/items/[id].svelte` could get its props from the `body` in the endpoint above:
9496

9597
```svelte
9698
/// file: src/routes/items/[id].svelte
@@ -102,6 +104,23 @@ The returned `body` corresponds to the page's props:
102104
<h1>{item.title}</h1>
103105
```
104106

107+
Because the page and route have the same URL, you will need to include an `accept: application/json` header to get JSON from the endpoint rather than HTML from the page. You can also get the raw data by appending `/__data.json` to the URL, e.g. `/items/__data.json`.
108+
109+
#### Standalone endpoints
110+
111+
Most commonly, endpoints exist to provide data to the page with which they're paired. They can, however, exist separately from pages. Standalone endpoints have slightly more flexibility over the returned `body` type — in addition to objects, they can return a `Uint8Array`.
112+
113+
Standalone endpoints can be given a file extension if desired, or accessed directly if not:
114+
115+
| filename | endpoint |
116+
| ----------------------------- | ---------- |
117+
| src/routes/data/index.json.js | /data.json |
118+
| src/routes/data.json.js | /data.json |
119+
| src/routes/data/index.js | /data |
120+
| src/routes/data.js | /data |
121+
122+
> Support for streaming request and response bodies is [coming soon](https://github.com/sveltejs/kit/issues/3419).
123+
105124
#### POST, PUT, PATCH, DELETE
106125

107126
Endpoints can handle any HTTP method — not just `GET` — by exporting the corresponding function:
@@ -191,8 +210,6 @@ export async function post({ request }) {
191210
</form>
192211
```
193212

194-
If you request the route with an `accept: application/json` header, SvelteKit will render the endpoint data as JSON, rather than the page as HTML. You can also get the raw data by appending `/__data.json` to the URL, e.g. `/items/__data.json`.
195-
196213
#### Body parsing
197214

198215
The `request` object is an instance of the standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) class. As such, accessing the request body is easy:
@@ -263,21 +280,6 @@ export default config;
263280

264281
> Using native `<form>` behaviour ensures your app continues to work when JavaScript fails or is disabled.
265282
266-
### Standalone endpoints
267-
268-
Most commonly, endpoints exist to provide data to the page with which they're paired. They can, however, exist separately from pages. Standalone endpoints have slightly more flexibility over the returned `body` type — in addition to objects, they can return a string or a `Uint8Array`.
269-
270-
> Support for streaming request and response bodies is [coming soon](https://github.com/sveltejs/kit/issues/3419).
271-
272-
Standalone endpoints can be given a file extension if desired, or accessed directly if not:
273-
274-
| filename | endpoint |
275-
| ----------------------------- | ---------- |
276-
| src/routes/data/index.json.js | /data.json |
277-
| src/routes/data.json.js | /data.json |
278-
| src/routes/data/index.js | /data |
279-
| src/routes/data.js | /data |
280-
281283
### Private modules
282284

283285
Files and directories with a leading `_` or `.` (other than [`.well-known`](https://en.wikipedia.org/wiki/Well-known_URI)) are private by default, meaning that they do not create routes (but can be imported by files that do). You can configure which modules are considered public or private with the [`routes`](/docs/configuration#routes) configuration.

0 commit comments

Comments
 (0)