2026-01-09 11:58:08 +08:00
|
|
|
import { notFound } from "next/navigation"
|
|
|
|
|
import { ChapterContent } from "@/components/chapter-content"
|
|
|
|
|
import { getSectionBySlug, getChapterBySectionSlug } from "@/lib/book-file-system"
|
2026-01-14 05:24:13 +00:00
|
|
|
import { specialSections, getSectionById } from "@/lib/book-data"
|
2026-01-09 11:58:08 +08:00
|
|
|
|
|
|
|
|
interface ReadPageProps {
|
|
|
|
|
params: Promise<{ id: string }>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const dynamic = "force-dynamic"
|
|
|
|
|
export const runtime = "nodejs"
|
|
|
|
|
|
|
|
|
|
export default async function ReadPage({ params }: ReadPageProps) {
|
|
|
|
|
const { id } = await params
|
|
|
|
|
|
|
|
|
|
if (id === "preface") {
|
2026-01-14 05:24:13 +00:00
|
|
|
return <ChapterContent section={specialSections.preface as any} partTitle="序言" chapterTitle="" />
|
2026-01-09 11:58:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (id === "epilogue") {
|
2026-01-14 05:24:13 +00:00
|
|
|
return <ChapterContent section={specialSections.epilogue as any} partTitle="尾声" chapterTitle="" />
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (id.startsWith("appendix-")) {
|
|
|
|
|
const appendixSection = specialSections.appendix.find((a) => a.id === id)
|
|
|
|
|
if (appendixSection) {
|
|
|
|
|
return <ChapterContent section={appendixSection as any} partTitle="附录" chapterTitle="" />
|
|
|
|
|
}
|
2026-01-09 11:58:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2026-01-14 05:24:13 +00:00
|
|
|
// 先从文件系统获取
|
2026-01-09 11:58:08 +08:00
|
|
|
const section = getSectionBySlug(id)
|
2026-01-14 05:24:13 +00:00
|
|
|
if (section) {
|
|
|
|
|
const context = getChapterBySectionSlug(id)
|
|
|
|
|
if (context) {
|
|
|
|
|
return <ChapterContent section={section} partTitle={context.part.title} chapterTitle={context.chapter.title} />
|
|
|
|
|
}
|
2026-01-09 11:58:08 +08:00
|
|
|
}
|
|
|
|
|
|
2026-01-14 05:24:13 +00:00
|
|
|
// 再从book-data获取
|
|
|
|
|
const bookSection = getSectionById(id)
|
|
|
|
|
if (bookSection) {
|
|
|
|
|
return <ChapterContent section={bookSection as any} partTitle="" chapterTitle="" />
|
2026-01-09 11:58:08 +08:00
|
|
|
}
|
|
|
|
|
|
2026-01-14 05:24:13 +00:00
|
|
|
notFound()
|
2026-01-09 11:58:08 +08:00
|
|
|
} catch (error) {
|
2026-01-21 15:49:12 +08:00
|
|
|
console.error("[Karuo] Error in ReadPage:", error)
|
2026-01-09 11:58:08 +08:00
|
|
|
notFound()
|
|
|
|
|
}
|
|
|
|
|
}
|