|
| 1 | +<script lang="ts"> |
| 2 | + import { goto } from '$app/navigation'; |
| 3 | + import { page } from '$app/stores'; |
| 4 | + import { onMount } from 'svelte'; |
| 5 | +
|
| 6 | + // The old Svelte 3 docs used one giant docs page for everything, with hashes marking sections. |
| 7 | + // This mapping does a best effort to redirect to the new docs. |
| 8 | + const mappings = [ |
| 9 | + ['before-we-begin', 'overview'], |
| 10 | + ['getting-started', 'getting-started'], |
| 11 | + ['component-format', 'component-fundamentals'], |
| 12 | + ['template-syntax-if', 'control-flow'], |
| 13 | + ['template-syntax-each', 'control-flow'], |
| 14 | + ['template-syntax-await', 'control-flow'], |
| 15 | + ['template-syntax-key', 'control-flow'], |
| 16 | + ['template-syntax-element-directives', 'basic-markup'], |
| 17 | + ['template-syntax-element-directives-bind', 'bindings'], |
| 18 | + ['template-syntax-element-directives-class', 'styles-and-classes'], |
| 19 | + ['template-syntax-element-directives-style', 'styles-and-classes'], |
| 20 | + ['template-syntax-element-directives-use-action', 'actions'], |
| 21 | + ['template-syntax-element-directives-transition-fn', 'transitions-and-animations'], |
| 22 | + ['template-syntax-element-directives-in-fn-out-fn', 'transitions-and-animations'], |
| 23 | + ['template-syntax-element-directives-animate-fn', 'transitions-and-animations'], |
| 24 | + ['template-syntax-component-directives', 'component fundamentals'], |
| 25 | + ['template-syntax-svelte', 'special-elements'], |
| 26 | + ['template-syntax', 'basic-markup'], |
| 27 | + ['run-time-svelte-store', 'svelte-store'], |
| 28 | + ['run-time-svelte-motion', 'svelte-motion'], |
| 29 | + ['run-time-svelte-transition', 'svelte-transition'], |
| 30 | + ['run-time-svelte-animate', 'svelte-animate'], |
| 31 | + ['run-time-svelte-easing', 'svelte-easing'], |
| 32 | + ['run-time-client-side-component-api', 'imperative-component-api'], |
| 33 | + ['run-time-custom-element-api', 'custom-elements'], |
| 34 | + ['run-time-server-side-component-api', 'imperative-component-api'], |
| 35 | + ['run-time-svelte', 'svelte'], |
| 36 | + ['run-time', 'svelte'], |
| 37 | + ['compile-time', 'svelte-compiler'], |
| 38 | + ['accessibility-warnings', 'TODO'] |
| 39 | + ]; |
| 40 | +
|
| 41 | + function get_url_to_redirect_to() { |
| 42 | + const hash = $page.url.hash.replace(/^#/i, ''); |
| 43 | +
|
| 44 | + if (!hash) return; |
| 45 | +
|
| 46 | + for (const [old_id, new_id] of mappings) { |
| 47 | + if (hash.startsWith(old_id)) return `/docs/svelte/${new_id}`; |
| 48 | + } |
| 49 | + } |
| 50 | +
|
| 51 | + onMount(() => { |
| 52 | + const redirect = get_url_to_redirect_to(); |
| 53 | + if (redirect) { |
| 54 | + goto(redirect, { replaceState: true }); |
| 55 | + } |
| 56 | + }); |
| 57 | +</script> |
| 58 | + |
1 | 59 | <div class="page">
|
2 | 60 | <div>
|
3 | 61 | <h2>Svelte</h2>
|
|
0 commit comments