Skip to content

Commit e2ede9c

Browse files
authored
fix: implement redirects for sveltekit types (#648)
another piece of #540
1 parent 87f4644 commit e2ede9c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

apps/svelte.dev/src/routes/docs/[...path]/+page.svelte

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,18 @@
3232
return;
3333
}
3434
35-
const id = hash.toLowerCase().replaceAll(':', '-');
35+
// kit/svelte4 replaced `:` character
36+
// e.g. we want to redirect progressive-enhancement-use-enhance to Progressive-enhancement-use:enhance
37+
// kit docs also had types in URL that we want to replace. e.g.
38+
// https://kit.svelte.dev/docs/types#public-types-loadevent
39+
// https://kit.svelte.dev/docs/types#private-types-cspdirectives
40+
const id = hash
41+
.toLowerCase()
42+
.replaceAll(':', '-')
43+
.replaceAll('public-types-', '')
44+
.replaceAll('private-types-', '');
3645
3746
for (const heading of content.querySelectorAll('[id]')) {
38-
// e.g. we want to redirect progressive-enhancement-use-enhance to Progressive-enhancement-use:enhance
3947
if (heading.id.toLowerCase().replaceAll(':', '-') === id) {
4048
goto(`#${heading.id}`, {
4149
replaceState: true

0 commit comments

Comments
 (0)