import fs from "fs"; import path from "path"; export default async function FilePage({ params, }: { params: Promise<{ path?: string[] }>; }) { const { path: segments = [] } = await params; // <-- FIXED const filePath = segments.join("/") || ""; // Resolve to actual file in /public const fullPath = path.join(process.cwd(), "public", filePath); // 404 if (!fs.existsSync(fullPath)) { return (
404 - File not found: /{filePath}
); } // Directory → list contents if (fs.lstatSync(fullPath).isDirectory()) { const files = fs.readdirSync(fullPath); return (

/{filePath}

{files.map((name) => (
- {name}
))}
); } // File → read contents const content = fs.readFileSync(fullPath, "utf8"); return (

/{filePath}

{content}
); }