Skip to content

Commit 3e82228

Browse files
committed
Switch track pages to force-dynamic rendering
1 parent d05b2c1 commit 3e82228

File tree

1 file changed

+4
-25
lines changed
  • apps/web/app/tracks/[...trackIds]

1 file changed

+4
-25
lines changed

apps/web/app/tracks/[...trackIds]/page.tsx

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { RedirectToLastSolved } from "../../../components/RedirectToLastSolved";
22
import { NotionAPI } from "notion-client";
33
import { redirect, notFound } from "next/navigation";
4-
import { getAllTracks, getProblem, getTrack } from "../../../components/utils";
5-
import { cache } from "react";
4+
import { getProblem, getTrack } from "../../../components/utils";
65
import { LessonView } from "../../../components/LessonView";
76

87
const notion = new NotionAPI();
9-
export const dynamic = "auto";
8+
export const dynamic = "force-dynamic";
109
// Dynamic Metadata
1110
export async function generateMetadata({ params }: { params: { trackIds: string[] } }) {
1211
const trackId = params.trackIds[0] || "";
@@ -21,7 +20,7 @@ export async function generateMetadata({ params }: { params: { trackIds: string[
2120
description: track.description,
2221
images: [
2322
{
24-
url: track.image || "/default-thumbnail.jpg", // Fallback to a default image if thumbnail is not available
23+
url: track.image || "/default-thumbnail.jpg",
2524
alt: `${track.title} Thumbnail`,
2625
},
2726
],
@@ -36,7 +35,7 @@ export async function generateMetadata({ params }: { params: { trackIds: string[
3635
description: "The track you are looking for does not exist.",
3736
images: [
3837
{
39-
url: "/default-thumbnail.jpg", // Use a default image if the track is not found
38+
url: "/default-thumbnail.jpg",
4039
alt: "Default Thumbnail",
4140
},
4241
],
@@ -45,26 +44,6 @@ export async function generateMetadata({ params }: { params: { trackIds: string[
4544
}
4645
}
4746

48-
export async function generateStaticParams() {
49-
try {
50-
const tracks = await cache(getAllTracks)();
51-
const allPages = tracks.map((t: any) =>
52-
t.problems.map((p: any) => {
53-
if (p.type === "Blog") {
54-
return {
55-
trackIds: [t.id, p.id],
56-
};
57-
}
58-
})
59-
);
60-
61-
return allPages.flat();
62-
} catch (e) {
63-
console.log(e);
64-
return [];
65-
}
66-
}
67-
6847
export default async function TrackComponent({ params }: { params: { trackIds: string[] } }) {
6948
const trackId: string = params.trackIds[0] || "";
7049
const problemId = params.trackIds[1];

0 commit comments

Comments
 (0)