Skip to content
Merged
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ dist
pnpm-lock.yaml
.vercel
_generated.md
land-110m.json
land-110m.json
/apps/svelte.dev/content/docs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ To create a layout that applies to every page, make a file called `src/routes/+l
<slot></slot>
```

If we create pages for `/`, `/about` and `/settings`...
If we create pages for ` / `, `/about` and `/settings`...

```html
/// file: src/routes/+page.svelte
Expand Down Expand Up @@ -291,7 +291,7 @@ If an error is thrown (either `error(...)` or an unexpected error), the response

### Receiving data

By exporting `POST`/`PUT`/`PATCH`/`DELETE`/`OPTIONS`/`HEAD` handlers, `+server.js` files can be used to create a complete API:
By exporting `POST` / `PUT` / `PATCH` / `DELETE` / `OPTIONS` / `HEAD` handlers, `+server.js` files can be used to create a complete API:

```svelte
<!--- file: src/routes/add/+page.svelte --->
Expand Down Expand Up @@ -362,8 +362,8 @@ export async function fallback({ request }) {

`+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:

- `PUT`/`PATCH`/`DELETE`/`OPTIONS` requests are always handled by `+server.js` since they do not apply to pages
- `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`.
- `PUT` / `PATCH` / `DELETE` / `OPTIONS` requests are always handled by `+server.js` since they do not apply to pages
- `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`.
- Responses to `GET` requests will include a `Vary: Accept` header, so that proxies and browsers cache HTML and JSON responses separately.

## $types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ self.addEventListener('fetch', (event) => {
const url = new URL(event.request.url);
const cache = await caches.open(CACHE);

// `build`/`files` can always be served from the cache
// `build` / `files` can always be served from the cache
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably not strictly necessary here. I don't know whether this still makes sense to do anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may as well be consistent

if (ASSETS.includes(url.pathname)) {
const response = await cache.match(url.pathname);

Expand Down
8 changes: 4 additions & 4 deletions apps/svelte.dev/content/docs/kit/30-advanced/70-packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ You should think carefully about whether or not the changes you make to your pac

`svelte-package` accepts the following options:

- `-w`/`--watch` — watch files in `src/lib` for changes and rebuild the package
- `-i`/`--input` — the input directory which contains all the files of the package. Defaults to `src/lib`
- `-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`
- `-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`
- `-w` / `--watch` — watch files in `src/lib` for changes and rebuild the package
- `-i` / `--input` — the input directory which contains all the files of the package. Defaults to `src/lib`
- `-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`
- `-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`
- `--tsconfig` - the path to a tsconfig or jsconfig. When not provided, searches for the next upper tsconfig/jsconfig in the workspace path.

## Publishing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const config = {
export default config;
```

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

```js
/// file: src/routes/+layout.server.js
Expand Down
2 changes: 1 addition & 1 deletion apps/svelte.dev/content/docs/kit/60-appendix/10-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function GET({ params, url }) {
}
```

(Note that you may also need to proxy `POST`/`PATCH` etc requests, and forward `request.headers`, depending on your needs.)
(Note that you may also need to proxy `POST` / `PATCH` etc requests, and forward `request.headers`, depending on your needs.)

### How do I use middleware?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: What are runes?
>
> A letter or mark used as a mystical or magic symbol.

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_.
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_.

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

Expand Down
2 changes: 1 addition & 1 deletion apps/svelte.dev/content/docs/svelte/02-runes/02-$state.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Todo {
}
```

> [!NOTE] The compiler transforms `done` and `text` into `get`/`set` methods on the class prototype referencing private fields.
> [!NOTE] The compiler transforms `done` and `text` into `get` / `set` methods on the class prototype referencing private fields.

## `$state.raw`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The context is then available to children of the component (including slotted co
- the state is not global, it's scoped to the component. That way it's safe to render your components on the server and not leak state
- it's clear that the state is not global but rather scoped to a specific component tree and therefore can't be used in other parts of your app

> [!NOTE] `setContext`/`getContext` must be called during component initialisation.
> [!NOTE] `setContext` / `getContext` must be called during component initialisation.

Context is not inherently reactive. If you need reactive values in context then you can pass a `$state` object into context, whose properties _will_ be reactive.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,14 +634,14 @@ As before, you can disable whitespace trimming by setting the `preserveWhitespac
Svelte 5 requires a modern browser (in other words, not Internet Explorer) for various reasons:

- it uses [`Proxies`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
- elements with `clientWidth`/`clientHeight`/`offsetWidth`/`offsetHeight` bindings use a [`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) rather than a convoluted `<iframe>` hack
- elements with `clientWidth` / `clientHeight` / `offsetWidth` / `offsetHeight` bindings use a [`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) rather than a convoluted `<iframe>` hack
- `<input type="range" bind:value={...} />` only uses an `input` event listener, rather than also listening for `change` events as a fallback

The `legacy` compiler option, which generated bulkier but IE-friendly code, no longer exists.

## Changes to compiler options

- The `false`/`true` (already deprecated previously) and the `"none"` values were removed as valid values from the `css` option
- The `false` / `true` (already deprecated previously) and the `"none"` values were removed as valid values from the `css` option
- The `legacy` option was repurposed
- The `hydratable` option has been removed. Svelte components are always hydratable now
- The `enableSourcemap` option has been removed. Source maps are always generated now, tooling can choose to ignore it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function unmount(component: Record<string, any>): void;

## untrack

Use `untrack` to prevent something from being treated as an `$effect`/`$derived` dependency.
Use `untrack` to prevent something from being treated as an `$effect` / `$derived` dependency.

https://svelte-5-preview.vercel.app/docs/functions#untrack

Expand Down
18 changes: 18 additions & 0 deletions packages/site-kit/src/lib/markdown/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,24 @@ export async function render_content_markdown(
// Save everything locally now
snippets.save(token.text, html);
}

// ensure that `foo`/`bar` is transformed to `foo` / `bar`
// https://github.com/sveltejs/svelte.dev/pull/577
const slash_index =
// @ts-expect-error
token.tokens?.findIndex((token) => token.type === 'text' && token.text === '/') ?? -1;

if (slash_index !== -1) {
// @ts-expect-error
const before = token.tokens[slash_index - 1];
// @ts-expect-error
const after = token.tokens[slash_index + 1];

if (before?.type === 'codespan' && after?.type === 'codespan') {
// @ts-expect-error
token.tokens[slash_index].raw = token.tokens[slash_index].text = ' / ';
}
}
},
text(token) {
// @ts-expect-error I think this is a bug in marked — some text tokens have children,
Expand Down
Loading