From 70aaaab5fcdc81751167982cff0e40272c5f97d6 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 27 Oct 2024 09:09:25 -0400 Subject: [PATCH 001/453] update blog posts (#640) * update blog posts * Update apps/svelte.dev/content/blog/2024-10-24-sv-the-svelte-cli.md Co-authored-by: Conduitry * update YouTube link --------- Co-authored-by: Conduitry Co-authored-by: Karim Jordan <113807903+karimfromjordan@users.noreply.github.com> --- apps/svelte.dev/content/blog/2024-10-22-svelte-5-is-alive.md | 2 +- apps/svelte.dev/content/blog/2024-10-24-sv-the-svelte-cli.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/svelte.dev/content/blog/2024-10-22-svelte-5-is-alive.md b/apps/svelte.dev/content/blog/2024-10-22-svelte-5-is-alive.md index e87439096d..a0d3af931d 100644 --- a/apps/svelte.dev/content/blog/2024-10-22-svelte-5-is-alive.md +++ b/apps/svelte.dev/content/blog/2024-10-22-svelte-5-is-alive.md @@ -87,7 +87,7 @@ For more details, see the [comprehensive Svelte 5 migration guide](/docs/svelte/ ## Our new CLI -Along with a new version of Svelte, we have a new Command Line Interface (CLI), `sv`, to go with it. You can learn all about it in [the `sv` announcement video](https://www.youtube.com/watch?v=fAPFsRP-mbc#t=3h15m40s) and in a forthcoming blog post. +Along with a new version of Svelte, we have a new Command Line Interface (CLI), `sv`, to go with it. You can learn all about it in [the announcement blog post](sv-the-svelte-cli). ## What’s next? diff --git a/apps/svelte.dev/content/blog/2024-10-24-sv-the-svelte-cli.md b/apps/svelte.dev/content/blog/2024-10-24-sv-the-svelte-cli.md index 0fd59b0908..f655f255fb 100644 --- a/apps/svelte.dev/content/blog/2024-10-24-sv-the-svelte-cli.md +++ b/apps/svelte.dev/content/blog/2024-10-24-sv-the-svelte-cli.md @@ -12,7 +12,7 @@ One of the most common question we hear is "how do I set up Tailwind on my new p
- +
Introducing sv at Svelte Summit Fall 2024
From 87f46444e4efccb292ec7345b865b61ee67bf652 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Mon, 28 Oct 2024 02:50:33 -0700 Subject: [PATCH 002/453] fix: update tutorial redirects (#671) --- apps/learn.svelte.dev/vercel.json | 54 +++++++++++++------------------ 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/apps/learn.svelte.dev/vercel.json b/apps/learn.svelte.dev/vercel.json index 0d622fbe27..806baa00c2 100644 --- a/apps/learn.svelte.dev/vercel.json +++ b/apps/learn.svelte.dev/vercel.json @@ -95,7 +95,7 @@ }, { "source": "/tutorial/event-forwarding", - "destination": "https://svelte.dev/tutorial/svelte/event-forwarding" + "destination": "https://github.com/sveltejs/svelte/blob/ac6d8c0bf4534221818c634286c7c9b1b7fd91d3/documentation/tutorial/05-events/05-event-forwarding/app-b/App.svelte" }, { "source": "/tutorial/dom-event-forwarding", @@ -131,47 +131,47 @@ }, { "source": "/tutorial/marked", - "destination": "https://svelte.dev/tutorial/svelte/marked" + "destination": "https://svelte.dev/tutorial/svelte/textarea-inputs" }, { "source": "/tutorial/onmount", - "destination": "https://svelte.dev/tutorial/svelte/onmount" + "destination": "https://svelte.dev/docs/svelte/lifecycle-hooks" }, { "source": "/tutorial/update", - "destination": "https://svelte.dev/tutorial/svelte/update" + "destination": "https://svelte.dev/docs/svelte/lifecycle-hooks" }, { "source": "/tutorial/elizabot", - "destination": "https://svelte.dev/tutorial/svelte/elizabot" + "destination": "https://github.com/sveltejs/svelte/blob/ac6d8c0bf4534221818c634286c7c9b1b7fd91d3/documentation/tutorial/07-lifecycle/03-update/text.md" }, { "source": "/tutorial/tick", - "destination": "https://svelte.dev/tutorial/svelte/tick" + "destination": "https://svelte.dev/docs/svelte/lifecycle-hooks#tick" }, { "source": "/tutorial/writable-stores", - "destination": "https://svelte.dev/tutorial/svelte/writable-stores" + "destination": "https://svelte.dev/tutorial/svelte/introducing-stores" }, { "source": "/tutorial/auto-subscriptions", - "destination": "https://svelte.dev/tutorial/svelte/auto-subscriptions" + "destination": "https://svelte.dev/docs/svelte/stores" }, { "source": "/tutorial/readable-stores", - "destination": "https://svelte.dev/tutorial/svelte/readable-stores" + "destination": "https://svelte.dev/docs/svelte/stores" }, { "source": "/tutorial/derived-stores", - "destination": "https://svelte.dev/tutorial/svelte/derived-stores" + "destination": "https://svelte.dev/docs/svelte/stores" }, { "source": "/tutorial/custom-stores", - "destination": "https://svelte.dev/tutorial/svelte/custom-stores" + "destination": "https://svelte.dev/docs/svelte/stores" }, { "source": "/tutorial/store-bindings", - "destination": "https://svelte.dev/tutorial/svelte/store-bindings" + "destination": "https://github.com/sveltejs/svelte/blob/ac6d8c0bf4534221818c634286c7c9b1b7fd91d3/documentation/tutorial/08-stores/06-store-bindings/text.md" }, { "source": "/tutorial/tweens", @@ -219,7 +219,7 @@ }, { "source": "/tutorial/animate", - "destination": "https://svelte.dev/tutorial/svelte/animate" + "destination": "https://svelte.dev/tutorial/svelte/animations" }, { "source": "/tutorial/actions", @@ -229,10 +229,6 @@ "source": "/tutorial/adding-parameters-to-actions", "destination": "https://svelte.dev/tutorial/svelte/adding-parameters-to-actions" }, - { - "source": "/tutorial/core", - "destination": "https://svelte.dev/tutorial/svelte/core" - }, { "source": "/tutorial/tippy.js", "destination": "https://svelte.dev/tutorial/svelte/tippy.js" @@ -283,23 +279,23 @@ }, { "source": "/tutorial/slots", - "destination": "https://svelte.dev/tutorial/svelte/slots" + "destination": "https://svelte.dev/docs/svelte/legacy-slots" }, { "source": "/tutorial/named-slots", - "destination": "https://svelte.dev/tutorial/svelte/named-slots" + "destination": "https://svelte.dev/docs/svelte/legacy-slots" }, { "source": "/tutorial/slot-fallbacks", - "destination": "https://svelte.dev/tutorial/svelte/slot-fallbacks" + "destination": "https://svelte.dev/docs/svelte/legacy-slots" }, { "source": "/tutorial/slot-props", - "destination": "https://svelte.dev/tutorial/svelte/slot-props" + "destination": "https://svelte.dev/docs/svelte/legacy-slots" }, { "source": "/tutorial/optional-slots", - "destination": "https://svelte.dev/tutorial/svelte/optional-slots" + "destination": "https://svelte.dev/docs/svelte/legacy-$slots" }, { "source": "/tutorial/context-api", @@ -307,11 +303,11 @@ }, { "source": "/tutorial/svelte-self", - "destination": "https://svelte.dev/tutorial/svelte/svelte-self" + "destination": "https://svelte.dev/docs/svelte/legacy-svelte-self" }, { "source": "/tutorial/svelte-component", - "destination": "https://svelte.dev/tutorial/svelte/svelte-component" + "destination": "https://svelte.dev/docs/svelte/legacy-svelte-component" }, { "source": "/tutorial/svelte-element", @@ -339,11 +335,11 @@ }, { "source": "/tutorial/svelte-options", - "destination": "https://svelte.dev/tutorial/svelte/svelte-options" + "destination": "https://svelte.dev/docs/svelte/svelte-options" }, { "source": "/tutorial/svelte-fragment", - "destination": "https://svelte.dev/tutorial/svelte/svelte-fragment" + "destination": "https://svelte.dev/docs/svelte/legacy-svelte-fragment" }, { "source": "/tutorial/sharing-code", @@ -355,7 +351,7 @@ }, { "source": "/tutorial/debug", - "destination": "https://svelte.dev/tutorial/svelte/debug" + "destination": "https://svelte.dev/docs/svelte/@debug" }, { "source": "/tutorial/congratulations", @@ -457,10 +453,6 @@ "source": "/tutorial/redirects", "destination": "https://svelte.dev/tutorial/kit/redirects" }, - { - "source": "/tutorial/xx-custom-error-messages", - "destination": "https://svelte.dev/tutorial/kit/xx-custom-error-messages" - }, { "source": "/tutorial/handle", "destination": "https://svelte.dev/tutorial/kit/handle" From e2ede9c82c53c8def3845a70802a9c2d0e044d22 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Mon, 28 Oct 2024 02:52:23 -0700 Subject: [PATCH 003/453] fix: implement redirects for sveltekit types (#648) another piece of #540 --- .../src/routes/docs/[...path]/+page.svelte | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/svelte.dev/src/routes/docs/[...path]/+page.svelte b/apps/svelte.dev/src/routes/docs/[...path]/+page.svelte index 763e332760..2f1ad1b9d8 100644 --- a/apps/svelte.dev/src/routes/docs/[...path]/+page.svelte +++ b/apps/svelte.dev/src/routes/docs/[...path]/+page.svelte @@ -32,10 +32,18 @@ return; } - const id = hash.toLowerCase().replaceAll(':', '-'); + // kit/svelte4 replaced `:` character + // e.g. we want to redirect progressive-enhancement-use-enhance to Progressive-enhancement-use:enhance + // kit docs also had types in URL that we want to replace. e.g. + // https://kit.svelte.dev/docs/types#public-types-loadevent + // https://kit.svelte.dev/docs/types#private-types-cspdirectives + const id = hash + .toLowerCase() + .replaceAll(':', '-') + .replaceAll('public-types-', '') + .replaceAll('private-types-', ''); for (const heading of content.querySelectorAll('[id]')) { - // e.g. we want to redirect progressive-enhancement-use-enhance to Progressive-enhancement-use:enhance if (heading.id.toLowerCase().replaceAll(':', '-') === id) { goto(`#${heading.id}`, { replaceState: true From 05c4dcfdb99635e0c64b434d406702ac7f70a793 Mon Sep 17 00:00:00 2001 From: GwangJin Kim Date: Mon, 28 Oct 2024 19:38:36 +0900 Subject: [PATCH 004/453] fix: change bullet points color and position (#646) fixes #542 --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> --- packages/site-kit/src/lib/components/Text.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/site-kit/src/lib/components/Text.svelte b/packages/site-kit/src/lib/components/Text.svelte index 7a8a77700c..aac3eae31b 100644 --- a/packages/site-kit/src/lib/components/Text.svelte +++ b/packages/site-kit/src/lib/components/Text.svelte @@ -376,9 +376,9 @@ li::before { content: ''; position: absolute; - top: calc(50% - 0.3rem); + top: 1.43rem; left: -1.8rem; - background-color: var(--sk-back-5); + background-color: var(--sk-text-4); width: 0.6rem; height: 0.6rem; border-radius: 50%; From 1d2e52dad783b43ee46cd74819085ea48b2e57c8 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:38:49 +0100 Subject: [PATCH 005/453] docs: sync repos (#677) * docs: sync repos * fix links --- .../docs/kit/20-core-concepts/10-routing.md | 45 ++++++++++++------- .../docs/kit/20-core-concepts/20-load.md | 35 ++++++++------- .../kit/20-core-concepts/30-form-actions.md | 25 +++++------ .../20-core-concepts/50-state-management.md | 18 ++++---- .../25-build-and-deploy/90-adapter-vercel.md | 4 +- .../kit/30-advanced/10-advanced-routing.md | 6 +-- .../content/docs/kit/30-advanced/20-hooks.md | 6 ++- .../docs/kit/30-advanced/65-snapshots.md | 2 +- .../kit/30-advanced/67-shallow-routing.md | 2 +- .../docs/kit/40-best-practices/03-auth.md | 23 ++++++++++ .../kit/40-best-practices/05-performance.md | 2 +- .../docs/kit/98-reference/10-@sveltejs-kit.md | 6 +-- .../content/docs/kit/98-reference/26-$lib.md | 16 ++++++- .../content/docs/kit/98-reference/54-types.md | 2 +- .../svelte/01-introduction/03-svelte-files.md | 2 + .../docs/svelte/02-runes/03-$derived.md | 2 + .../docs/svelte/02-runes/04-$effect.md | 2 +- .../docs/svelte/03-template-syntax/12-use.md | 2 +- .../docs/svelte/06-runtime/02-context.md | 4 +- .../svelte/06-runtime/03-lifecycle-hooks.md | 9 ++-- .../svelte/07-misc/07-v5-migration-guide.md | 18 ++++---- .../docs/svelte/98-reference/20-svelte.md | 8 ++-- .../svelte/98-reference/21-svelte-action.md | 2 +- 23 files changed, 152 insertions(+), 89 deletions(-) create mode 100644 apps/svelte.dev/content/docs/kit/40-best-practices/03-auth.md diff --git a/apps/svelte.dev/content/docs/kit/20-core-concepts/10-routing.md b/apps/svelte.dev/content/docs/kit/20-core-concepts/10-routing.md index 0c48a2b2c2..66d2af54bb 100644 --- a/apps/svelte.dev/content/docs/kit/20-core-concepts/10-routing.md +++ b/apps/svelte.dev/content/docs/kit/20-core-concepts/10-routing.md @@ -37,17 +37,22 @@ A `+page.svelte` component defines a page of your app. By default, pages are ren Home ``` +Pages can receive data from `load` functions via the `data` prop. + ```svelte

{data.title}

{@html data.content}
``` +> [!LEGACY] In Svelte 4 +> In Svelte 4, you'd use `export let data` instead + > [!NOTE] Note that SvelteKit uses `` elements to navigate between routes, rather than a framework-specific `` component. ### +page.js @@ -153,21 +158,29 @@ But in many apps, there are elements that should be visible on _every_ page, suc 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... -```html - +```svelte + + +{@render children()} ``` -...but we can add whatever markup, styles and behaviour we want. The only requirement is that the component includes a `` for the page content. For example, let's add a nav bar: +...but we can add whatever markup, styles and behaviour we want. The only requirement is that the component includes a `@render` tag for the page content. For example, let's add a nav bar: + +```svelte + + -```html -/// file: src/routes/+layout.svelte - +{@render children()} ``` If we create pages for `/`, `/about` and `/settings`... @@ -196,8 +209,8 @@ We can create a layout that only applies to pages below `/settings` (while inher ```svelte

Settings

@@ -208,7 +221,7 @@ We can create a layout that only applies to pages below `/settings` (while inher {/each}
- +{@render children()} ``` You can see how `data` is populated by looking at the `+layout.js` example in the next section just below. @@ -239,8 +252,8 @@ Data returned from a layout's `load` function is also available to all its child ```svelte @@ -370,13 +383,13 @@ export async function fallback({ request }) { 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. -For example, annotating `export let data` with `PageData` (or `LayoutData`, for a `+layout.svelte` file) tells TypeScript that the type of `data` is whatever was returned from `load`: +For example, annotating `let { data } = $props()` with `PageData` (or `LayoutData`, for a `+layout.svelte` file) tells TypeScript that the type of `data` is whatever was returned from `load`: ```svelte ``` diff --git a/apps/svelte.dev/content/docs/kit/20-core-concepts/20-load.md b/apps/svelte.dev/content/docs/kit/20-core-concepts/20-load.md index 3e50259a33..9de2b83ead 100644 --- a/apps/svelte.dev/content/docs/kit/20-core-concepts/20-load.md +++ b/apps/svelte.dev/content/docs/kit/20-core-concepts/20-load.md @@ -24,14 +24,17 @@ export function load({ params }) { ```svelte

{data.post.title}

{@html data.post.content}
``` +> [!LEGACY] In Svelte 4 +> In Svelte 4, you'd use `export let data` instead + Thanks to the generated `$types` module, we get full type safety. A `load` function in a `+page.js` file runs both on the server and in the browser (unless combined with `export const ssr = false`, in which case it will [only run in the browser](page-options#ssr)). If your `load` function should _always_ run on the server (because it uses private environment variables, for example, or accesses a database) then it would go in a `+page.server.js` instead. @@ -85,13 +88,13 @@ export async function load() { ```svelte
- - + + {@render children()}