File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -3,17 +3,20 @@ import DifficultyPage from './DifficultyPage';
3
3
import type { Metadata } from 'next' ;
4
4
5
5
type Props = {
6
- params : { id : TopicId }
6
+ params : Promise < { id : TopicId } >
7
7
} ;
8
8
9
+ export const dynamic = 'force-static' ;
10
+
9
11
export function generateStaticParams ( ) {
10
12
return Object . keys ( topics ) . map ( ( id ) => ( {
11
13
id,
12
14
} ) ) ;
13
15
}
14
16
15
17
export async function generateMetadata ( { params } : Props ) : Promise < Metadata > {
16
- const topic = topics [ params . id ] ;
18
+ const { id } = await params ;
19
+ const topic = topics [ id ] ;
17
20
18
21
if ( ! topic ) {
19
22
return {
@@ -28,7 +31,8 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
28
31
} ;
29
32
}
30
33
31
- export default function Topic ( { params } : Props ) {
32
- const topic = topics [ params . id ] ;
33
- return < DifficultyPage id = { params . id } title = { topic . title } description = { topic . description } /> ;
34
+ export default async function Topic ( { params } : Props ) {
35
+ const { id } = await params ;
36
+ const topic = topics [ id ] ;
37
+ return < DifficultyPage id = { id } title = { topic . title } description = { topic . description } /> ;
34
38
}
Original file line number Diff line number Diff line change @@ -15,13 +15,14 @@ export function generateStaticParams() {
15
15
}
16
16
17
17
type Props = {
18
- params : { id : TopicId ; difficulty : string }
18
+ params : Promise < { id : TopicId ; difficulty : string } >
19
19
} ;
20
20
21
21
export async function generateMetadata ( { params } : Props ) : Promise < Metadata > {
22
- const topic = topics [ params . id ] ;
23
- const difficultyName = params . difficulty === 'easy' ? 'Surface Level' :
24
- params . difficulty === 'medium' ? 'Medium Depth' :
22
+ const { id, difficulty } = await params ;
23
+ const topic = topics [ id ] ;
24
+ const difficultyName = difficulty === 'easy' ? 'Surface Level' :
25
+ difficulty === 'medium' ? 'Medium Depth' :
25
26
'Deep Questions' ;
26
27
27
28
if ( ! topic ) {
@@ -37,7 +38,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
37
38
} ;
38
39
}
39
40
40
- export default async function Questions ( { params } : { params : Promise < { id : string ; difficulty : string } > } ) {
41
+ export default async function Questions ( { params } : Props ) {
41
42
const { id, difficulty } = await params ;
42
43
const topic = topics [ id as TopicId ] ;
43
44
You can’t perform that action at this time.
0 commit comments