Skip to content

Commit 7ce30c0

Browse files
committed
separate code spans
1 parent 61b4c0d commit 7ce30c0

File tree

13 files changed

+59
-132
lines changed

13 files changed

+59
-132
lines changed

apps/svelte.dev/content/docs/kit/20-core-concepts/10-routing.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Each route directory contains one or more _route files_, which can be identified
1414

1515
We'll introduce these files in a moment in more detail, but here are a few simple rules to help you remember how SvelteKit's routing works:
1616

17-
* All files can run on the server
18-
* All files run on the client except `+server` files
19-
* `+layout` and `+error` files apply to subdirectories as well as the directory they live in
17+
- All files can run on the server
18+
- All files run on the client except `+server` files
19+
- `+layout` and `+error` files apply to subdirectories as well as the directory they live in
2020

2121
## +page
2222

@@ -291,7 +291,7 @@ If an error is thrown (either `error(...)` or an unexpected error), the response
291291
292292
### Receiving data
293293
294-
By exporting `POST`/`PUT`/`PATCH`/`DELETE`/`OPTIONS`/`HEAD` handlers, `+server.js` files can be used to create a complete API:
294+
By exporting `POST` / `PUT` / `PATCH` / `DELETE` / `OPTIONS` / `HEAD` handlers, `+server.js` files can be used to create a complete API:
295295
296296
```svelte
297297
<!--- file: src/routes/add/+page.svelte --->
@@ -362,8 +362,8 @@ export async function fallback({ request }) {
362362
363363
`+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:
364364
365-
- `PUT`/`PATCH`/`DELETE`/`OPTIONS` requests are always handled by `+server.js` since they do not apply to pages
366-
- `GET`/`POST`/`HEAD` 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`.
365+
- `PUT` / `PATCH` / `DELETE` / `OPTIONS` requests are always handled by `+server.js` since they do not apply to pages
366+
- `GET` / `POST` / `HEAD` 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`.
367367
- Responses to `GET` requests will include a `Vary: Accept` header, so that proxies and browsers cache HTML and JSON responses separately.
368368
369369
## $types

apps/svelte.dev/content/docs/kit/20-core-concepts/30-form-actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ Some forms don't need to `POST` data to the server — search inputs, for exampl
509509
<form action="/search">
510510
<label>
511511
Search
512-
<input name="q">
512+
<input name="q" />
513513
</label>
514514
</form>
515515
```

apps/svelte.dev/content/docs/kit/20-core-concepts/40-page-options.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ If you encounter an error like 'The following routes were marked as prerenderabl
8080

8181
Since these routes cannot be dynamically server-rendered, this will cause errors when people try to access the route in question. There are a few ways to fix it:
8282

83-
* Ensure that SvelteKit can find the route by following links from [`config.kit.prerender.entries`](configuration#prerender) or the [`entries`](#entries) page option. Add links to dynamic routes (i.e. pages with `[parameters]` ) to this option if they are not found through crawling the other entry points, else they are not prerendered because SvelteKit doesn't know what value the parameters should have. Pages not marked as prerenderable will be ignored and their links to other pages will not be crawled, even if some of them would be prerenderable.
84-
* Ensure that SvelteKit can find the route by discovering a link to it from one of your other prerendered pages that have server-side rendering enabled.
85-
* Change `export const prerender = true` to `export const prerender = 'auto'`. Routes with `'auto'` can be dynamically server rendered
83+
- Ensure that SvelteKit can find the route by following links from [`config.kit.prerender.entries`](configuration#prerender) or the [`entries`](#entries) page option. Add links to dynamic routes (i.e. pages with `[parameters]` ) to this option if they are not found through crawling the other entry points, else they are not prerendered because SvelteKit doesn't know what value the parameters should have. Pages not marked as prerenderable will be ignored and their links to other pages will not be crawled, even if some of them would be prerenderable.
84+
- Ensure that SvelteKit can find the route by discovering a link to it from one of your other prerendered pages that have server-side rendering enabled.
85+
- Change `export const prerender = true` to `export const prerender = 'auto'`. Routes with `'auto'` can be dynamically server rendered
8686

8787
## entries
8888

@@ -104,10 +104,7 @@ This can be done with [`config.kit.prerender.entries`](configuration#prerender),
104104
/// file: src/routes/blog/[slug]/+page.server.js
105105
/** @type {import('./$types').EntryGenerator} */
106106
export function entries() {
107-
return [
108-
{ slug: 'hello-world' },
109-
{ slug: 'another-blog-post' }
110-
];
107+
return [{ slug: 'hello-world' }, { slug: 'another-blog-post' }];
111108
}
112109

113110
export const prerender = true;
@@ -139,11 +136,11 @@ export const csr = false;
139136

140137
Disabling CSR does not ship any JavaScript to the client. This means:
141138

142-
* The webpage should work with HTML and CSS only.
143-
* `<script>` tags inside all Svelte components are removed.
144-
* `<form>` elements cannot be [progressively enhanced](form-actions#Progressive-enhancement).
145-
* Links are handled by the browser with a full-page navigation.
146-
* Hot Module Replacement (HMR) will be disabled.
139+
- The webpage should work with HTML and CSS only.
140+
- `<script>` tags inside all Svelte components are removed.
141+
- `<form>` elements cannot be [progressively enhanced](form-actions#Progressive-enhancement).
142+
- Links are handled by the browser with a full-page navigation.
143+
- Hot Module Replacement (HMR) will be disabled.
147144

148145
You can enable `csr` during development (for example to take advantage of HMR) like so:
149146

@@ -200,7 +197,7 @@ export const config = {
200197
foo: {
201198
bar: true
202199
}
203-
}
200+
};
204201
```
205202

206203
...is overridden by this page configuration...
@@ -212,7 +209,7 @@ export const config = {
212209
foo: {
213210
baz: true
214211
}
215-
}
212+
};
216213
```
217214

218215
...which results in the config value `{ runtime: 'edge', regions: ['us1', 'us2'], foo: { baz: true } }` for that page.

apps/svelte.dev/content/docs/kit/30-advanced/40-service-workers.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const CACHE = `cache-${version}`;
3232

3333
const ASSETS = [
3434
...build, // the app itself
35-
...files // everything in `static`
35+
...files // everything in `static`
3636
];
3737

3838
self.addEventListener('install', (event) => {
@@ -64,7 +64,7 @@ self.addEventListener('fetch', (event) => {
6464
const url = new URL(event.request.url);
6565
const cache = await caches.open(CACHE);
6666

67-
// `build`/`files` can always be served from the cache
67+
// `build` / `files` can always be served from the cache
6868
if (ASSETS.includes(url.pathname)) {
6969
const response = await cache.match(url.pathname);
7070

@@ -134,6 +134,7 @@ Setting up proper types for service workers requires some manual setup. Inside y
134134
135135
const sw = /** @type {ServiceWorkerGlobalScope} */ (/** @type {unknown} */ (self));
136136
```
137+
137138
```generated-ts
138139
/// <reference types="@sveltejs/kit" />
139140
/// <reference no-default-lib="true"/>

apps/svelte.dev/content/docs/kit/30-advanced/70-packaging.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,7 @@ If your package has files with side effects, you can specify them in an array:
146146
```json
147147
/// file: package.json
148148
{
149-
"sideEffects": [
150-
"**/*.css",
151-
"./dist/sideEffectfulFile.js"
152-
]
149+
"sideEffects": ["**/*.css", "./dist/sideEffectfulFile.js"]
153150
}
154151
```
155152

@@ -222,10 +219,10 @@ You should think carefully about whether or not the changes you make to your pac
222219

223220
`svelte-package` accepts the following options:
224221

225-
- `-w`/`--watch` — watch files in `src/lib` for changes and rebuild the package
226-
- `-i`/`--input` — the input directory which contains all the files of the package. Defaults to `src/lib`
227-
- `-o`/`--output` — the output directory where the processed files are written to. Your `package.json`'s `exports` should point to files inside there, and the `files` array should include that folder. Defaults to `dist`
228-
- `-t`/`--types` — whether or not to create type definitions (`d.ts` files). We strongly recommend doing this as it fosters ecosystem library quality. Defaults to `true`
222+
- `-w` / `--watch` — watch files in `src/lib` for changes and rebuild the package
223+
- `-i` / `--input` — the input directory which contains all the files of the package. Defaults to `src/lib`
224+
- `-o` / `--output` — the output directory where the processed files are written to. Your `package.json`'s `exports` should point to files inside there, and the `files` array should include that folder. Defaults to `dist`
225+
- `-t` / `--types` — whether or not to create type definitions (`d.ts` files). We strongly recommend doing this as it fosters ecosystem library quality. Defaults to `true`
229226
- `--tsconfig` - the path to a tsconfig or jsconfig. When not provided, searches for the next upper tsconfig/jsconfig in the workspace path.
230227

231228
## Publishing

apps/svelte.dev/content/docs/kit/40-best-practices/20-seo.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const config = {
7575
export default config;
7676
```
7777

78-
...disabling `csr` in your root `+layout.js`/`+layout.server.js`...
78+
...disabling `csr` in your root `+layout.js` / `+layout.server.js`...
7979

8080
```js
8181
/// file: src/routes/+layout.server.js
@@ -86,7 +86,8 @@ export const csr = false;
8686

8787
```html
8888
<html amp>
89-
...
89+
...
90+
</html>
9091
```
9192

9293
...and transforming the HTML using `transformPageChunk` along with `transform` imported from `@sveltejs/amp`:

apps/svelte.dev/content/docs/kit/60-appendix/10-faq.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ onMount(() => {
142142
```
143143
144144
Finally, you may also consider using an `{#await}` block:
145+
145146
```svelte
146147
<!--- file: index.svelte --->
147148
<script>
@@ -177,7 +178,7 @@ export function GET({ params, url }) {
177178
}
178179
```
179180
180-
(Note that you may also need to proxy `POST`/`PATCH` etc requests, and forward `request.headers`, depending on your needs.)
181+
(Note that you may also need to proxy `POST` / `PATCH` etc requests, and forward `request.headers`, depending on your needs.)
181182
182183
### How do I use middleware?
183184

apps/svelte.dev/content/docs/kit/98-reference/50-configuration.md

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ Any additional options required by tooling that integrates with Svelte.
124124
</div>
125125
</div></div>
126126

127-
128-
129127
## KitConfig
130128

131129
The `kit` property configures SvelteKit, and can have the following properties:
@@ -142,8 +140,6 @@ Your [adapter](https://kit.svelte.dev/docs/adapters) is run when executing `vite
142140

143141
<div class="ts-block-property-children">
144142

145-
146-
147143
</div>
148144

149145
## alias
@@ -184,8 +180,6 @@ const config = {
184180
185181
<div class="ts-block-property-children">
186182

187-
188-
189183
</div>
190184

191185
## appDir
@@ -202,16 +196,12 @@ If `paths.assets` is specified, there will be two app directories — `${paths.a
202196

203197
<div class="ts-block-property-children">
204198

205-
206-
207199
</div>
208200

209201
## csp
210202

211203
<div class="ts-block-property-bullets">
212204

213-
214-
215205
</div>
216206

217207
[Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) configuration. CSP helps to protect your users against cross-site scripting (XSS) attacks, by limiting the places resources can be loaded from. For example, a configuration like this...
@@ -298,8 +288,6 @@ Directives that will be added to `Content-Security-Policy-Report-Only` headers.
298288

299289
<div class="ts-block-property-bullets">
300290

301-
302-
303291
</div>
304292

305293
Protection against [cross-site request forgery (CSRF)](https://owasp.org/www-community/attacks/csrf) attacks.
@@ -343,16 +331,12 @@ Note that it is generally not supported to embed multiple SvelteKit apps on the
343331

344332
<div class="ts-block-property-children">
345333

346-
347-
348334
</div>
349335

350336
## env
351337

352338
<div class="ts-block-property-bullets">
353339

354-
355-
356340
</div>
357341

358342
Environment variable configuration
@@ -424,8 +408,6 @@ A prefix that signals that an environment variable is unsafe to expose to client
424408

425409
<div class="ts-block-property-bullets">
426410

427-
428-
429411
</div>
430412

431413
Where to find various files within your project.
@@ -652,8 +634,6 @@ Inline CSS inside a `<style>` block at the head of the HTML. This option is a nu
652634
653635
<div class="ts-block-property-children">
654636

655-
656-
657637
</div>
658638

659639
## moduleExtensions
@@ -668,8 +648,6 @@ An array of file extensions that SvelteKit will treat as modules. Files with ext
668648

669649
<div class="ts-block-property-children">
670650

671-
672-
673651
</div>
674652

675653
## outDir
@@ -684,16 +662,12 @@ The directory that SvelteKit writes files to during `dev` and `build`. You shoul
684662

685663
<div class="ts-block-property-children">
686664

687-
688-
689665
</div>
690666

691667
## output
692668

693669
<div class="ts-block-property-bullets">
694670

695-
696-
697671
</div>
698672

699673
Options related to the build output format
@@ -718,6 +692,7 @@ preloadStrategy?: 'modulepreload' | 'preload-js' | 'preload-mjs';
718692

719693
SvelteKit will preload the JavaScript modules needed for the initial page to avoid import 'waterfalls', resulting in faster application startup. There
720694
are three strategies with different trade-offs:
695+
721696
- `modulepreload` - uses `<link rel="modulepreload">`. This delivers the best results in Chromium-based browsers, in Firefox 115+, and Safari 17+. It is ignored in older browsers.
722697
- `preload-js` - uses `<link rel="preload">`. Prevents waterfalls in Chromium and Safari, but Chromium will parse each module twice (once as a script, once as a module). Causes modules to be requested twice in Firefox. This is a good setting if you want to maximise performance for users on iOS devices at the cost of a very slight degradation for Chromium users.
723698
- `preload-mjs` - uses `<link rel="preload">` but with the `.mjs` extension which prevents double-parsing in Chromium. Some static webservers will fail to serve .mjs files with a `Content-Type: application/javascript` header, which will cause your application to break. If that doesn't apply to you, this is the option that will deliver the best performance for the largest number of users, until `modulepreload` is more widely supported.
@@ -731,12 +706,8 @@ are three strategies with different trade-offs:
731706

732707
<div class="ts-block-property-bullets">
733708

734-
735-
736709
</div>
737710

738-
739-
740711
<div class="ts-block-property-children">
741712

742713
<div class="ts-block-property">
@@ -813,8 +784,6 @@ In 1.0, `undefined` was a valid value, which was set by default. In that case, i
813784

814785
<div class="ts-block-property-bullets">
815786

816-
817-
818787
</div>
819788

820789
See [Prerendering](https://kit.svelte.dev/docs/page-options#prerender).
@@ -874,7 +843,7 @@ entries?: Array<'*' | `/${string}`>;
874843

875844
</div>
876845

877-
An array of pages to prerender, or start crawling from (if `crawl: true`). The `*` string includes all routes containing no required `[parameters]` with optional parameters included as being empty (since SvelteKit doesn't know what value any parameters should have).
846+
An array of pages to prerender, or start crawling from (if `crawl: true`). The `*` string includes all routes containing no required `[parameters]` with optional parameters included as being empty (since SvelteKit doesn't know what value any parameters should have).
878847

879848
</div>
880849
</div>
@@ -1000,12 +969,8 @@ The value of `url.origin` during prerendering; useful if it is included in rende
1000969

1001970
<div class="ts-block-property-bullets">
1002971

1003-
1004-
1005972
</div>
1006973

1007-
1008-
1009974
<div class="ts-block-property-children">
1010975

1011976
<div class="ts-block-property">
@@ -1053,12 +1018,8 @@ Determine which files in your `static` directory will be available in `$service-
10531018
10541019
<div class="ts-block-property-bullets">
10551020
1056-
1057-
10581021
</div>
10591022
1060-
1061-
10621023
<div class="ts-block-property-children">
10631024
10641025
<div class="ts-block-property">
@@ -1089,14 +1050,13 @@ This is useful for extending a shared `tsconfig.json` in a monorepo root, for ex
10891050
10901051
<div class="ts-block-property-bullets">
10911052
1092-
1093-
10941053
</div>
10951054
10961055
Client-side navigation can be buggy if you deploy a new version of your app while people are using it. If the code for the new page is already loaded, it may have stale content; if it isn't, the app's route manifest may point to a JavaScript file that no longer exists.
10971056
SvelteKit helps you solve this problem through version management.
10981057
If SvelteKit encounters an error while loading the page and detects that a new version has been deployed (using the `name` specified here, which defaults to a timestamp of the build) it will fall back to traditional full-page navigation.
10991058
Not all navigations will result in an error though, for example if the JavaScript for the next page is already loaded. If you still want to force a full-page navigation in these cases, use techniques such as setting the `pollInterval` and then using `beforeNavigate`:
1059+
11001060
```html
11011061
/// file: +layout.svelte
11021062
<script>

apps/svelte.dev/content/docs/svelte/02-runes/01-what-are-runes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: What are runes?
66
>
77
> A letter or mark used as a mystical or magic symbol.
88
9-
Runes are symbols that you use in `.svelte` and `.svelte.js`/`.svelte.ts` files to control the Svelte compiler. If you think of Svelte as a language, runes are part of the syntax — they are _keywords_.
9+
Runes are symbols that you use in `.svelte` and `.svelte.js` / `.svelte.ts` files to control the Svelte compiler. If you think of Svelte as a language, runes are part of the syntax — they are _keywords_.
1010

1111
Runes have a `$` prefix and look like functions:
1212

0 commit comments

Comments
 (0)