Skip to content

Commit 676a7da

Browse files
committed
chore: redirect logic-blocks page
1 parent c517e42 commit 676a7da

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

apps/svelte.dev/src/hooks.server.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ const mappings = new Map([
88
['/docs/custom-elements-api', '/docs/svelte/custom-elements'],
99
['/docs/element-directives', '/docs/svelte/basic-markup'], // no good mapping for this one
1010
['/docs/introduction', '/docs/svelte/overview'],
11-
['/docs/logic-blocks', '/docs/svelte/basic-markup'], // no good mapping for this one
1211
['/docs/server-side-component-api', '/docs/svelte/legacy-component-api'],
1312
['/docs/special-elements', '/docs/svelte/svelte-window'], // no good mapping for this one
1413
['/docs/special-tags', '/docs/svelte/basic-markup'],
15-
// can't map this, as this is now a redirect to the overview page: ['/docs/svelte', '/docs/svelte/svelte'],
14+
// ['/docs/svelte', '/docs/svelte/svelte'], - can't map this. /docs/svelte is now a redirect to the overview page
1615
['/docs/svelte-action', '/docs/svelte/svelte-action'],
1716
['/docs/svelte-animate', '/docs/svelte/svelte-animate'],
1817
['/docs/svelte-compiler', '/docs/svelte/svelte-compiler'],
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<script>
2+
import { onMount } from 'svelte';
3+
import { goto } from '$app/navigation';
4+
import { page } from '$app/stores';
5+
6+
const docs = new Map([
7+
['if', ['{#if ...}', '/docs/svelte/if']],
8+
['each', ['{#each ...}', '/docs/svelte/each']],
9+
['await', ['{#key ...}', '/docs/svelte/await']],
10+
['key', ['{#await ...}', '/docs/svelte/key']]
11+
]);
12+
13+
function get_url_to_redirect_to() {
14+
const hash = $page.url.hash.slice(1);
15+
if (hash === '') return;
16+
17+
const new_docs = docs.get(hash);
18+
return new_docs && new_docs[1];
19+
}
20+
21+
onMount(() => {
22+
const redirect = get_url_to_redirect_to();
23+
if (redirect) {
24+
goto(redirect, { replaceState: true });
25+
}
26+
});
27+
</script>
28+
29+
<svelte:head>
30+
<meta name="robots" content="noindex" />
31+
</svelte:head>
32+
33+
<div class="page">
34+
<h1>This page no longer exists</h1>
35+
36+
<h2>You may be looking for:</h2>
37+
38+
<ul>
39+
{#each docs as doc}
40+
<li>
41+
<span style="font-weight:bold">{doc[1][0]}</span> is now located at
42+
<a href={doc[1][1]}>{doc[1][1]}</a>
43+
</li>
44+
{/each}
45+
</ul>
46+
</div>
47+
48+
<style>
49+
.page {
50+
padding: var(--sk-page-padding-top) var(--sk-page-padding-side);
51+
max-width: var(--sk-page-content-width);
52+
box-sizing: content-box;
53+
margin: auto;
54+
text-wrap: balance;
55+
}
56+
57+
h1 {
58+
padding-bottom: 2rem;
59+
}
60+
61+
ul {
62+
list-style-type: none;
63+
}
64+
</style>

0 commit comments

Comments
 (0)