Skip to content

Commit 2e51e7c

Browse files
committed
add dynamic content page path
1 parent 05c9a56 commit 2e51e7c

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

app/content/[...path]/page.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { contentManager } from "@/lib/contentManager";
2+
import React from "react";
3+
4+
export default function Content({ params }: { params: { path: string[] } }) {
5+
const { Page } = contentManager.parseMdxFile(params.path.join("/") + ".mdx");
6+
return <Page />;
7+
}
8+
export async function generateStaticParams() {
9+
const outline = contentManager.outline;
10+
const pathList: { path: string[] }[] = [];
11+
12+
outline.map((item) => {
13+
item.steps.map((step) => {
14+
pathList.push({
15+
path: [item.folderName, step.fileName.replaceAll(".mdx", "")],
16+
});
17+
});
18+
});
19+
console.log(pathList);
20+
return pathList;
21+
}

lib/contentManager.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,6 @@ export default class ContentManager {
9696
return contentOutline;
9797
}
9898
}
99+
100+
const contentManager = new ContentManager();
101+
export { contentManager };

0 commit comments

Comments
 (0)