Skip to content

Commit f953c9d

Browse files
authored
Overhaul site-kit (#7892)
* use local fork of site-kit * start organising CSS a bit * remove unused theme/typo classes * remove some unused stuff * remove some more unused stuff * remove some unused files * namespace/tidy up design tokens * use namespaced tokens * remove banner * tweaks * start work on dark mode * fix, tidy up * fixes * lockfile * fix css bug * update error page * update error page * fix search * consolidate some css * tidy up * more tidying up * more tidying up * tidy * update styles * tweak * WIP dark mode * fixes and tweaks * tweaks * dark mode colours * more stuff * homepage stuff * shrink sidebar a touch * tweak breakpoints * tweaks * tweak * search list dark mode colours * more tweaks * tweak breakpoints * tweak * oops * use correct heading levels * hide scrollbar * tweak dimensions * simplify breakpoints * try fix scrollbar css * tidy up * remove webkit scrollbar stuff * dont cover scrollbar * fix search box colours * clamp scrollable area * ok try this
1 parent a6fa65e commit f953c9d

File tree

99 files changed

+2461
-955
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+2461
-955
lines changed

documentation/docs/10-getting-started/10-introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
title: Introduction
33
---
44

5-
### Before we begin
5+
## Before we begin
66

77
> SvelteKit is in release candidate phase for 1.0 while we address reported issues and add polish. If you get stuck, reach out for help in the [Discord chatroom](https://svelte.dev/chat).
88
>
99
> See the [migration guides](/docs/migrating) for help upgrading from Sapper.
1010
11-
### What is SvelteKit?
11+
## What is SvelteKit?
1212

1313
SvelteKit is a framework for building extremely high-performance web apps.
1414

documentation/docs/10-getting-started/20-creating-a-project.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ There are two basic concepts:
2020

2121
Try editing the files to get a feel for how everything works – you may not need to bother reading the rest of this guide!
2222

23-
### Editor setup
23+
## Editor setup
2424

2525
We recommend using [Visual Studio Code (aka VS Code)](https://code.visualstudio.com/download) with [the Svelte extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode), but [support also exists for numerous other editors](https://sveltesociety.dev/tools#editor-support).

documentation/docs/10-getting-started/30-project-structure.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ my-project/
3030

3131
You'll also find common files like `.gitignore` and `.npmrc` (and `.prettierrc` and `.eslintrc.cjs` and so on, if you chose those options when running `npm create svelte@latest`).
3232

33-
### Project files
33+
## Project files
3434

35-
#### src
35+
### src
3636

3737
The `src` directory contains the meat of your project.
3838

@@ -53,34 +53,34 @@ The `src` directory contains the meat of your project.
5353

5454
You can use `.ts` files instead of `.js` files, if using TypeScript.
5555

56-
#### static
56+
### static
5757

5858
Any static assets that should be served as-is, like `robots.txt` or `favicon.png`, go in here.
5959

60-
#### tests
60+
### tests
6161

6262
If you chose to add tests to your project during `npm create svelte@latest`, they will live in this directory.
6363

64-
#### package.json
64+
### package.json
6565

6666
Your `package.json` file must include `@sveltejs/kit`, `svelte` and `vite` as `devDependencies`.
6767

6868
When you create a project with `npm create svelte@latest`, you'll also notice that `package.json` includes `"type": "module"`. This means that `.js` files are interpreted as native JavaScript modules with `import` and `export` keywords. Legacy CommonJS files need a `.cjs` file extension.
6969

70-
#### svelte.config.js
70+
### svelte.config.js
7171

7272
This file contains your Svelte and SvelteKit [configuration](/docs/configuration).
7373

74-
#### tsconfig.json
74+
### tsconfig.json
7575

7676
This file (or `jsconfig.json`, if you prefer type-checked `.js` files over `.ts` files) configures TypeScript, if you added typechecking during `npm create svelte@latest`. Since SvelteKit relies on certain configuration being set a specific way, it generates its own `.svelte-kit/tsconfig.json` file which your own config `extends`.
7777

78-
#### vite.config.js
78+
### vite.config.js
7979

8080
A SvelteKit project is really just a [Vite](https://vitejs.dev) project that uses the [`@sveltejs/kit/vite`](/docs/modules#sveltejs-kit-vite) plugin, along with any other [Vite configuration](https://vitejs.dev/config/).
8181

82-
### Other files
82+
## Other files
8383

84-
#### .svelte-kit
84+
### .svelte-kit
8585

8686
As you develop and build your project, SvelteKit will generate files in a `.svelte-kit` directory (configurable as [`outDir`](/docs/configuration#outdir)). You can ignore its contents, and delete them at any time (they will be regenerated when you next `dev` or `build`).

documentation/docs/10-getting-started/40-web-standards.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ These APIs are available in all modern browsers and in many non-browser environm
88

99
In particular, you'll get comfortable with the following:
1010

11-
### Fetch APIs
11+
## Fetch APIs
1212

1313
SvelteKit uses [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch) for getting data from the network. It's available in [hooks](/docs/hooks) and [server routes](/docs/routing#server) as well as in the browser.
1414

1515
> A special version of `fetch` is available in [`load`](/docs/load) functions for invoking endpoints directly during server-side rendering, without making an HTTP call, while preserving credentials. (To make credentialled fetches in server-side code outside `load`, you must explicitly pass `cookie` and/or `authorization` headers.) It also allows you to make relative requests, whereas server-side `fetch` normally requires a fully qualified URL.
1616
1717
Besides `fetch` itself, the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) includes the following interfaces:
1818

19-
#### Request
19+
### Request
2020

2121
An instance of [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) is accessible in [hooks](/docs/hooks) and [server routes](/docs/routing#server) as `event.request`. It contains useful methods like `request.json()` and `request.formData()` for getting data that was posted to an endpoint.
2222

23-
#### Response
23+
### Response
2424

2525
An instance of [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) is returned from `await fetch(...)` and handlers in `+server.js` files. Fundamentally, a SvelteKit app is a machine for turning a `Request` into a `Response`.
2626

27-
#### Headers
27+
### Headers
2828

2929
The [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers) interface allows you to read incoming `request.headers` and set outgoing `response.headers`:
3030

@@ -45,7 +45,7 @@ export function GET(event) {
4545
}
4646
```
4747

48-
### FormData
48+
## FormData
4949

5050
When dealing with HTML native form submissions you'll be working with [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) objects.
5151

@@ -68,15 +68,15 @@ export async function POST(event) {
6868
}
6969
```
7070
71-
### Stream APIs
71+
## Stream APIs
7272
7373
Most of the time, your endpoints will return complete data, as in the `userAgent` example above. Sometimes, you may need to return a response that's too large to fit in memory in one go, or is delivered in chunks, and for this the platform provides [streams](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API) — [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream), [WritableStream](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream) and [TransformStream](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream).
7474
75-
### URL APIs
75+
## URL APIs
7676
7777
URLs are represented by the [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) interface, which includes useful properties like `origin` and `pathname` (and, in the browser, `hash`). This interface shows up in various places — `event.url` in [hooks](/docs/hooks) and [server routes](/docs/routing#server), [`$page.url`](/docs/modules#$app-stores) in [pages](/docs/routing#page), `from` and `to` in [`beforeNavigate` and `afterNavigate`](/docs/modules#$app-navigation) and so on.
7878
79-
#### URLSearchParams
79+
### URLSearchParams
8080
8181
Wherever you encounter a URL, you can access query parameters via `url.searchParams`, which is an instance of [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams):
8282
@@ -93,7 +93,7 @@ export {};
9393
const foo = url.searchParams.get('foo');
9494
```
9595
96-
### Web Crypto
96+
## Web Crypto
9797
9898
The [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) is made available via the `crypto` global. It's used internally for [Content Security Policy](/docs/configuration#csp) headers, but you can also use it for things like generating UUIDs:
9999

documentation/docs/20-core-concepts/10-routing.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ At the heart of SvelteKit is a _filesystem-based router_. The routes of your app
1212
1313
Each route directory contains one or more _route files_, which can be identified by their `+` prefix.
1414

15-
### +page
15+
## +page
1616

17-
#### +page.svelte
17+
### +page.svelte
1818

1919
A `+page.svelte` component defines a page of your app. By default, pages are rendered both on the server ([SSR](/docs/glossary#ssr)) for the initial request and in the browser ([CSR](/docs/glossary#csr-and-spa)) for subsequent navigation.
2020

@@ -44,7 +44,7 @@ A `+page.svelte` component defines a page of your app. By default, pages are ren
4444

4545
> Note that SvelteKit uses `<a>` elements to navigate between routes, rather than a framework-specific `<Link>` component.
4646
47-
#### +page.js
47+
### +page.js
4848

4949
Often, a page will need to load some data before it can be rendered. For this, we add a `+page.js` (or `+page.ts`, if you're TypeScript-inclined) module that exports a `load` function:
5050

@@ -75,7 +75,7 @@ As well as `load`, `+page.js` can export values that configure the page's behavi
7575

7676
You can find more information about these in [page options](/docs/page-options).
7777

78-
#### +page.server.js
78+
### +page.server.js
7979

8080
If your `load` function can only run on the server — for example, if it needs to fetch data from a database or you need to access private [environment variables](/docs/modules#$env-static-private) like API keys — then you can rename `+page.js` to `+page.server.js` and change the `PageLoad` type to `PageServerLoad`.
8181

@@ -114,7 +114,7 @@ Like `+page.js`, `+page.server.js` can export [page options](/docs/page-options)
114114

115115
A `+page.server.js` file can also export _actions_. If `load` lets you read data from the server, `actions` let you write data _to_ the server using the `<form>` element. To learn how to use them, see the [form actions](/docs/form-actions) section.
116116

117-
### +error
117+
## +error
118118

119119
If an error occurs during `load`, SvelteKit will render a default error page. You can customise this error page on a per-route basis by adding an `+error.svelte` file:
120120

@@ -133,13 +133,13 @@ SvelteKit will 'walk up the tree' looking for the closest error boundary — if
133133
134134
You can read more about error handling [here](/docs/errors).
135135

136-
### +layout
136+
## +layout
137137

138138
So far, we've treated pages as entirely standalone components — upon navigation, the existing `+page.svelte` component will be destroyed, and a new one will take its place.
139139

140140
But in many apps, there are elements that should be visible on _every_ page, such as top-level navigation or a footer. Instead of repeating them in every `+page.svelte`, we can put them in _layouts_.
141141

142-
#### +layout.svelte
142+
### +layout.svelte
143143

144144
To create a layout that applies to every page, make a file called `src/routes/+layout.svelte`. The default layout (the one that SvelteKit uses if you don't bring your own) looks like this...
145145

@@ -203,7 +203,7 @@ We can create a layout that only applies to pages below `/settings` (while inher
203203

204204
By default, each layout inherits the next layout above it. Sometimes that isn't what you want - in this case, [advanced layouts](/docs/advanced-routing#advanced-layouts) can help you.
205205

206-
#### +layout.js
206+
### +layout.js
207207

208208
Just like `+page.svelte` loading data from `+page.js`, your `+layout.svelte` component can get data from a [`load`](/docs/load) function in `+layout.js`.
209209

@@ -236,13 +236,13 @@ Data returned from a layout's `load` function is also available to all its child
236236

237237
> Often, layout data is unchanged when navigating between pages. SvelteKit will intelligently re-run [`load`](/docs/load) functions when necessary.
238238
239-
#### +layout.server.js
239+
### +layout.server.js
240240

241241
To run your layout's `load` function on the server, move it to `+layout.server.js`, and change the `LayoutLoad` type to `LayoutServerLoad`.
242242

243243
Like `+layout.js`, `+layout.server.js` can export [page options](/docs/page-options)`prerender`, `ssr` and `csr`.
244244

245-
### +server
245+
## +server
246246

247247
As well as pages, you can define routes with a `+server.js` file (sometimes referred to as an 'API route' or an 'endpoint'), which gives you full control over the response. Your `+server.js` file (or `+server.ts`) exports functions corresponding to HTTP verbs like `GET`, `POST`, `PATCH`, `PUT` and `DELETE` that take a `RequestEvent` argument and return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object.
248248

@@ -275,7 +275,7 @@ You can use the [`error`](/docs/modules#sveltejs-kit-error), [`redirect`](/docs/
275275
276276
If an error is thrown (either `throw error(...)` or an unexpected error), the response will be a JSON representation of the error or a fallback error page — which can be customised via `src/error.html` — depending on the `Accept` header. The [`+error.svelte`](#error) component will _not_ be rendered in this case. You can read more about error handling [here](/docs/errors).
277277
278-
#### Receiving data
278+
### Receiving data
279279
280280
By exporting `POST`/`PUT`/`PATCH`/`DELETE` handlers, `+server.js` files can be used to create a complete API:
281281
@@ -319,14 +319,14 @@ export async function POST({ request }) {
319319
320320
> In general, [form actions](/docs/form-actions) are a better way to submit data from the browser to the server.
321321
322-
#### Content negotiation
322+
### Content negotiation
323323
324324
`+server.js` files can be placed in the same directory as `+page` files, allowing the same route to be either a page or an API endpoint. To determine which, SvelteKit applies the following rules:
325325
326326
- `PUT`/`PATCH`/`DELETE` requests are always handled by `+server.js` since they do not apply to pages
327327
- `GET`/`POST` requests are treated as page requests if the `accept` header prioritises `text/html` (in other words, it's a browser page request), else they are handled by `+server.js`
328328
329-
### $types
329+
## $types
330330
331331
Throughout the examples above, we've been importing types from a `$types.d.ts` file. This is a file SvelteKit creates for you in a hidden directory if you're using TypeScript (or JavaScript with JSDoc type annotations) to give you type safety when working with your root files.
332332
@@ -342,7 +342,7 @@ For example, annotating `export let data` with `PageData` (or `LayoutData`, for
342342
343343
In turn, annotating the `load` function with `PageLoad`, `PageServerLoad`, `LayoutLoad` or `LayoutServerLoad` (for `+page.js`, `+page.server.js`, `+layout.js` and `+layout.server.js` respectively) ensures that `params` and the return value are correctly typed.
344344
345-
### Other files
345+
## Other files
346346
347347
Any other files inside a route directory are ignored by SvelteKit. This means you can colocate components and utility modules with the routes that need them.
348348

0 commit comments

Comments
 (0)