Skip to content

Commit 5877aed

Browse files
chore: redirect logic-blocks page (#629)
* chore: redirect logic-blocks page * refactor into reusable component * tweak * simplify * simplify --------- Co-authored-by: Rich Harris <[email protected]>
1 parent 7b942ae commit 5877aed

File tree

3 files changed

+65
-2
lines changed

3 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: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<script lang="ts">
2+
import { goto } from '$app/navigation';
3+
import { Text } from '@sveltejs/site-kit/components';
4+
5+
interface Props {
6+
docs: Map<string, string[]>;
7+
}
8+
9+
const { docs }: Props = $props();
10+
11+
$effect(() => {
12+
const hash = location.hash.slice(1);
13+
if (hash === '') return;
14+
15+
const new_docs = docs.get(hash);
16+
if (new_docs) {
17+
goto(new_docs[1], { replaceState: true });
18+
}
19+
});
20+
</script>
21+
22+
<svelte:head>
23+
<meta name="robots" content="noindex" />
24+
</svelte:head>
25+
26+
<div class="page">
27+
<header>
28+
<h1>This page no longer exists</h1>
29+
</header>
30+
31+
<Text>
32+
<p>You may be looking for one of the following:</p>
33+
34+
<ul>
35+
{#each docs.values() as [title, href]}
36+
<li>
37+
<span style="font-weight:bold">{title}</span> is now
38+
<a {href}>here</a>
39+
</li>
40+
{/each}
41+
</ul>
42+
</Text>
43+
</div>
44+
45+
<style>
46+
.page {
47+
padding: var(--sk-page-padding-top) var(--sk-page-padding-side) var(--sk-page-padding-bottom);
48+
max-width: var(--sk-page-content-width);
49+
box-sizing: content-box;
50+
margin: auto;
51+
}
52+
</style>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script>
2+
import RemovedPage from '../RemovedPage.svelte';
3+
4+
const docs = new Map([
5+
['if', ['{#if ...}', '/docs/svelte/if']],
6+
['each', ['{#each ...}', '/docs/svelte/each']],
7+
['await', ['{#key ...}', '/docs/svelte/await']],
8+
['key', ['{#await ...}', '/docs/svelte/key']]
9+
]);
10+
</script>
11+
12+
<RemovedPage {docs} />

0 commit comments

Comments
 (0)