-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: separate tutorial URLs into svelte and kit (#304)
* chore: separate tutorial URLs into svelte and kit - gives us more leeway with duplicated slugs if needed later on - makes URL a bit more organized - will make it easier to set dedicated headers for the SvelteKit tutorial (#301) - fixes a bug with redirects not being picked up due to prerendering not coming across old slugs * fix logic * fix a bunch of links or remove obsolete ones that have no replacement
- Loading branch information
1 parent
9ee57ca
commit 04916af
Showing
44 changed files
with
74 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
43 changes: 43 additions & 0 deletions
43
apps/svelte.dev/src/routes/tutorial/[...slug]/+page.server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { redirect } from '@sveltejs/kit'; | ||
import { load_exercise, parts } from './content.server'; | ||
|
||
export const prerender = true; | ||
|
||
const redirects = new Map([ | ||
['reactive-assignments', 'svelte/state'], | ||
['reactive-declarations', 'svelte/derived-state'], | ||
['reactive-statements', 'svelte/effects'], | ||
['updating-arrays-and-objects', 'svelte/deep-state'], | ||
['event-modifiers', 'svelte/capturing'], | ||
['dom-event-forwarding', 'svelte/spreading-events'] | ||
]); | ||
|
||
export async function load({ params }) { | ||
if (!params.slug || params.slug === 'svelte') redirect(307, '/tutorial/svelte/welcome-to-svelte'); | ||
if (params.slug === 'kit') redirect(307, '/tutorial/kit/introducing-sveltekit'); | ||
|
||
const r = redirects.get(params.slug); | ||
if (r) redirect(307, r); | ||
if (!params.slug.includes('/')) redirect(307, `/tutorial/svelte/${params.slug}`); | ||
|
||
return { | ||
exercise: await load_exercise(params.slug) | ||
}; | ||
} | ||
|
||
export function entries() { | ||
// These are not findable by the router, but we need to know about them for redirects | ||
|
||
// So that old tutorial/... routes can redirect to new tutorial/svelte/... | ||
const entries = parts | ||
.filter((part) => !part.slug.includes('sveltekit')) | ||
.flatMap((part) => part.chapters) | ||
.flatMap((chapter) => | ||
chapter.exercises.map((exercise) => ({ slug: exercise.slug.split('/').pop()! })) | ||
); | ||
|
||
// So that redirects from these URLs to /tutorial/<svelte/kit>/... work | ||
entries.push({ slug: 'svelte' }, { slug: 'kit' }); | ||
|
||
return entries; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 0 additions & 22 deletions
22
apps/svelte.dev/src/routes/tutorial/[slug]/+page.server.js
This file was deleted.
Oops, something went wrong.