import fs from "fs"; import path from "path"; export default function FilePage({ params }: { params: { path?: string[] } }) { const filePath = params.path?.join("/") || ""; // Resolve to actual file in public folder const fullPath = path.join(process.cwd(), "public", filePath); // If folder or file missing if (!fs.existsSync(fullPath)) { return (
404 - File not found: /{filePath}
); } // If it's a folder, list its contents if (fs.lstatSync(fullPath).isDirectory()) { const files = fs.readdirSync(fullPath); return (

/{filePath}

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

/{filePath}

{content}
); }