File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
apps/svelte.dev/src/routes/docs/[...path] Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 1
1
import { docs } from '$lib/server/content' ;
2
+ import { redirect } from '@sveltejs/kit' ;
2
3
import { error } from '@sveltejs/kit' ;
3
4
4
5
export const prerender = true ;
5
6
6
7
export async function load ( { params } ) {
7
- const page = docs . topics [ params . path . split ( '/' ) [ 0 ] ] ;
8
+ const topic = params . path . split ( '/' ) [ 0 ] ;
9
+ const document = docs . topics [ topic ] ;
8
10
9
- if ( ! page ) {
11
+ if ( ! document ) {
10
12
error ( 404 , 'Not found' ) ;
11
13
}
12
14
15
+ if ( params . path === topic ) {
16
+ redirect ( 307 , `/${ document . children [ 0 ] . children [ 0 ] . slug } ` ) ;
17
+ }
18
+
13
19
return {
14
- sections : page . children
20
+ sections : document . children
15
21
} ;
16
22
}
Original file line number Diff line number Diff line change 1
1
import { docs } from '$lib/server/content' ;
2
2
import { render_content } from '$lib/server/renderer' ;
3
- import { error , redirect } from '@sveltejs/kit' ;
3
+ import { error } from '@sveltejs/kit' ;
4
4
5
5
export async function load ( { params } ) {
6
6
const document = docs . pages [ params . path ] ;
7
7
8
8
if ( ! document ) {
9
- const topic = docs . topics [ params . path ] ;
10
- if ( topic ) {
11
- redirect ( 307 , `/${ topic . children [ 0 ] . children [ 0 ] . slug } ` ) ;
12
- }
13
9
error ( 404 ) ;
14
10
}
15
11
You can’t perform that action at this time.
0 commit comments