Skip to content

Commit 9948924

Browse files
committed
merge main
2 parents 8f4c6d0 + ce8edeb commit 9948924

File tree

32 files changed

+527
-167
lines changed

32 files changed

+527
-167
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-docs/index.ts
3+
title: Icons
4+
---
5+
6+
## CSS
7+
8+
A great way to use icons is to define them purely via CSS. Iconify offers support for [many popular icon sets](https://icon-sets.iconify.design/) that [can be included via CSS](https://iconify.design/docs/usage/css/). This method can also be used with popular CSS frameworks by leveraging the Iconify [Tailwind CSS plugin](https://iconify.design/docs/usage/css/tailwind/) or [UnoCSS plugin](https://iconify.design/docs/usage/css/unocss/). As opposed to libraries based on Svelte components, it doesn't require each icon to be imported into your `.svelte` file.
9+
10+
## Svelte
11+
12+
There are many [icon libraries for Svelte](https://www.sveltesociety.dev/packages?category=icons). When choosing an icon library, it is recommended to avoid those that provide a `.svelte` file per icon as these libraries can have thousands of `.svelte` files which really slow down [Vite's dependency optimization](https://vite.dev/guide/dep-pre-bundling.html). This can become especially pathological if the icons are imported both via an umbrella import and subpath import [as described in the `vite-plugin-svelte` FAQ](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#what-is-going-on-with-vite-and-pre-bundling-dependencies).

apps/svelte.dev/content/docs/kit/40-best-practices/07-images.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,6 @@ Using a content delivery network (CDN) can allow you to optimize these images dy
153153

154154
CDNs can generally be used without any need for a library. However, there are a number of libraries with Svelte support that make it easier. [`@unpic/svelte`](https://unpic.pics/img/svelte/) is a CDN-agnostic library with support for a large number of providers. You may also find that specific CDNs like [Cloudinary](https://svelte.cloudinary.dev/) have Svelte support. Finally, some content management systems (CMS) which support Svelte (such as [Contentful](https://www.contentful.com/sveltekit-starter-guide/), [Storyblok](https://github.com/storyblok/storyblok-svelte), and [Contentstack](https://www.contentstack.com/docs/developers/sample-apps/build-a-starter-website-with-sveltekit-and-contentstack)) have built-in support for image handling.
155155

156-
## Icons
157-
158-
A great way to use icons is to define them purely in CSS. Iconify offers a huge set of icons [available via CSS](https://iconify.design/docs/usage/css/).
159-
160-
For icons defined in `.svelte` files, it is recommended to avoid libraries that provide a `.svelte` file per icon. These libraries can have thousands of `.svelte` files which really slow down Vite's dependency optimization. This can become especially pathological if the icons are imported both via an umbrella import and subpath import [as described in the `vite-plugin-svelte` FAQ](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#what-is-going-on-with-vite-and-pre-bundling-dependencies).
161-
162156
## Best practices
163157

164158
- For each image type, use the appropriate solution from those discussed above. You can mix and match all three solutions in one project. For example, you may use Vite's built-in handling to provide images for `<meta>` tags, display images on your homepage with `@sveltejs/enhanced-img`, and display user-submitted content with a dynamic approach.

apps/svelte.dev/content/docs/kit/98-reference/[email protected]

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ type: Exclude<NavigationType, 'leave'>;
497497
<div class="ts-block-property-details">
498498

499499
The type of navigation:
500-
- `enter`: The app has hydrated
500+
- `enter`: The app has hydrated/started
501501
- `form`: The user submitted a `<form>`
502502
- `link`: Navigation was triggered by a link click
503503
- `goto`: Navigation was triggered by a `goto(...)` call or a redirect
@@ -1650,7 +1650,7 @@ The URL that is navigated to
16501650

16511651
## NavigationType
16521652

1653-
- `enter`: The app has hydrated
1653+
- `enter`: The app has hydrated/started
16541654
- `form`: The user submitted a `<form>` with a GET method
16551655
- `leave`: The user is leaving the app by closing the tab or using the back/forward buttons to go to a different document
16561656
- `link`: Navigation was triggered by a link click

apps/svelte.dev/content/docs/svelte/01-introduction/02-getting-started.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-doc
33
title: Getting started
44
---
55

6-
We recommend using [SvelteKit](../kit), the official application framework from the Svelte team powered by [Vite](https://vite.dev/):
6+
We recommend using [SvelteKit](../kit), which lets you [build almost anything](../kit/project-types). It's the official application framework from the Svelte team and powered by [Vite](https://vite.dev/). Create a new project with:
77

88
```bash
99
npx sv create myapp
@@ -16,7 +16,9 @@ Don't worry if you don't know Svelte yet! You can ignore all the nice features S
1616

1717
## Alternatives to SvelteKit
1818

19-
You can also use Svelte directly with Vite by running `npm create vite@latest` and selecting the `svelte` option. With this, `npm run build` will generate HTML, JS and CSS files inside the `dist` directory using [vite-plugin-svelte](https://github.com/sveltejs/vite-plugin-svelte). In most cases, you will probably need to [choose a routing library](faq#Is-there-a-router) as well.
19+
You can also use Svelte directly with Vite by running `npm create vite@latest` and selecting the `svelte` option. With this, `npm run build` will generate HTML, JS, and CSS files inside the `dist` directory using [vite-plugin-svelte](https://github.com/sveltejs/vite-plugin-svelte). In most cases, you will probably need to [choose a routing library](faq#Is-there-a-router) as well.
20+
21+
>[!NOTE] Vite is often used in standalone mode to build [single page apps (SPAs)](../kit/glossary#SPA), which you can also [build with SvelteKit](../kit/single-page-apps).
2022
2123
There are also plugins for [Rollup](https://github.com/sveltejs/rollup-plugin-svelte), [Webpack](https://github.com/sveltejs/svelte-loader) [and a few others](https://sveltesociety.dev/packages?category=build-plugins), but we recommend Vite.
2224

apps/svelte.dev/content/docs/svelte/07-misc/99-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ However, you can use any router library. A lot of people use [page.js](https://g
9797

9898
If you prefer a declarative HTML approach, there's the isomorphic [svelte-routing](https://github.com/EmilTholin/svelte-routing) library and a fork of it called [svelte-navigator](https://github.com/mefechoel/svelte-navigator) containing some additional functionality.
9999

100-
If you need hash-based routing on the client side, check out [svelte-spa-router](https://github.com/ItalyPaleAle/svelte-spa-router) or [abstract-state-router](https://github.com/TehShrike/abstract-state-router/).
100+
If you need hash-based routing on the client side, check out the [hash option](https://svelte.dev/docs/kit/configuration#router) in SvelteKit, [svelte-spa-router](https://github.com/ItalyPaleAle/svelte-spa-router), or [abstract-state-router](https://github.com/TehShrike/abstract-state-router/).
101101

102102
[Routify](https://routify.dev) is another filesystem-based router, similar to SvelteKit's router. Version 3 supports Svelte's native SSR.
103103

apps/svelte.dev/content/docs/svelte/98-reference/.generated/compile-errors.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,12 @@ Cannot access a computed property of a rune
660660
`%name%` is not a valid rune
661661
```
662662

663+
### rune_invalid_spread
664+
665+
```
666+
`%rune%` cannot be called with a spread argument
667+
```
668+
663669
### rune_invalid_usage
664670

665671
```

apps/svelte.dev/content/docs/svelte/98-reference/30-compiler-errors.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,12 @@ Cannot access a computed property of a rune
665665
`%name%` is not a valid rune
666666
```
667667

668+
### rune_invalid_spread
669+
670+
```
671+
`%rune%` cannot be called with a spread argument
672+
```
673+
668674
### rune_invalid_usage
669675

670676
```

apps/svelte.dev/src/lib/tutorial/adapters/rollup/index.svelte.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function create(): Promise<Adapter> {
4545
.filter((f): f is File => f.name.startsWith('/src/lib/') && f.type === 'file')
4646
.map((f) => ({ ...f, name: f.name.slice(9) })),
4747
{
48-
runes: true
48+
// TODO support Tailwind here?
4949
}
5050
);
5151
}

apps/svelte.dev/src/routes/(authed)/playground/[id]/+page.svelte

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
if (!hash && !saved) {
7373
repl?.set({
7474
// TODO make this munging unnecessary (using JSON instead of structuredClone for better browser compat)
75-
files: JSON.parse(JSON.stringify(data.gist.components)).map(munge)
75+
files: JSON.parse(JSON.stringify(data.gist.components)).map(munge),
76+
tailwind: false // TODO
7677
});
7778
7879
modified = false;
@@ -92,7 +93,7 @@
9293
name = recovered.name;
9394
}
9495
95-
repl.set({ files });
96+
repl.set({ files, tailwind: recovered.tailwind ?? false });
9697
} catch {
9798
alert(`Couldn't load the code from the URL. Make sure you copied the link correctly.`);
9899
}
@@ -155,7 +156,8 @@
155156
async function update_hash() {
156157
// Only change hash when necessary to avoid polluting everyone's browser history
157158
if (modified) {
158-
const json = JSON.stringify({ name, files: repl.toJSON().files });
159+
const { files, tailwind } = repl.toJSON();
160+
const json = JSON.stringify({ name, files, tailwind });
159161
await set_hash(json);
160162
}
161163
}
@@ -210,7 +212,8 @@
210212
if (modified) {
211213
// we can't save to the hash because it's an async operation, so we use
212214
// a short-lived sessionStorage value instead
213-
const json = JSON.stringify({ name, files: repl.toJSON().files });
215+
const { files, tailwind } = repl.toJSON();
216+
const json = JSON.stringify({ name, files, tailwind });
214217
sessionStorage.setItem(STORAGE_KEY, json);
215218
}
216219
}}

apps/svelte.dev/src/routes/(authed)/playground/[id]/embed/+page.svelte

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import { Repl } from '@sveltejs/repl';
66
import { mapbox_setup } from '../../../../../config.js';
77
import { page } from '$app/state';
8+
import { decode_and_decompress_text } from '../gzip.js';
9+
import type { File } from 'editor';
810
911
let { data } = $props();
1012
@@ -25,10 +27,41 @@
2527
});
2628
}
2729
30+
// TODO make this munging unnecessary
31+
function munge(data: any): File {
32+
const basename = `${data.name}.${data.type}`;
33+
34+
return {
35+
type: 'file',
36+
name: basename,
37+
basename,
38+
contents: data.source,
39+
text: true
40+
};
41+
}
42+
43+
async function set_files() {
44+
const hash = location.hash.slice(1);
45+
46+
if (!hash) {
47+
repl?.set({
48+
files: data.gist.components.map(munge),
49+
tailwind: false // TODO
50+
});
51+
52+
return;
53+
}
54+
55+
try {
56+
const recovered = JSON.parse(await decode_and_decompress_text(hash));
57+
repl.set({ files: recovered.files, tailwind: recovered.tailwind ?? false });
58+
} catch {
59+
alert(`Couldn't load the code from the URL. Make sure you copied the link correctly.`);
60+
}
61+
}
62+
2863
afterNavigate(() => {
29-
repl?.set({
30-
files: data.gist.components
31-
});
64+
set_files();
3265
});
3366
3467
const relaxed = $derived(data.gist.relaxed || (data.user && data.user.id === data.gist.owner));
@@ -51,7 +84,7 @@
5184
can_escape
5285
injectedJS={mapbox_setup}
5386
previewTheme={theme.current}
54-
embedded
87+
embedded={page.url.searchParams.has('output-only') ? 'output-only' : true}
5588
/>
5689
{/if}
5790
</div>

0 commit comments

Comments
 (0)