Skip to content

Commit 9291a9f

Browse files
committed
fix: build errs
1 parent bd6fd5c commit 9291a9f

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/app/topics/[id]/page.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ import DifficultyPage from './DifficultyPage';
33
import type { Metadata } from 'next';
44

55
type Props = {
6-
params: { id: TopicId }
6+
params: Promise<{ id: TopicId }>
77
};
88

9+
export const dynamic = 'force-static';
10+
911
export function generateStaticParams() {
1012
return Object.keys(topics).map((id) => ({
1113
id,
1214
}));
1315
}
1416

1517
export async function generateMetadata({ params }: Props): Promise<Metadata> {
16-
const topic = topics[params.id];
18+
const { id } = await params;
19+
const topic = topics[id];
1720

1821
if (!topic) {
1922
return {
@@ -28,7 +31,8 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
2831
};
2932
}
3033

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} />;
3438
}

src/app/topics/[id]/questions/[difficulty]/page.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ export function generateStaticParams() {
1515
}
1616

1717
type Props = {
18-
params: { id: TopicId; difficulty: string }
18+
params: Promise<{ id: TopicId; difficulty: string }>
1919
};
2020

2121
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' :
2526
'Deep Questions';
2627

2728
if (!topic) {
@@ -37,7 +38,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
3738
};
3839
}
3940

40-
export default async function Questions({ params }: { params: Promise<{ id: string; difficulty: string }> }) {
41+
export default async function Questions({ params }: Props) {
4142
const { id, difficulty } = await params;
4243
const topic = topics[id as TopicId];
4344

0 commit comments

Comments
 (0)