import Link from "next/link"; import path from "path"; import { promises as fs } from "fs"; const APP_DIR = path.join(process.cwd(), "app"); async function collectRoutes(rootDir: string): Promise { const routes: string[] = []; async function walk(relativeDir: string) { const absoluteDir = path.join(rootDir, relativeDir); const entries = await fs.readdir(absoluteDir, { withFileTypes: true }); const names = entries.map((e) => e.name); if (names.includes("page.tsx")) { const routePath = relativeDir === "" ? "/" : `/${relativeDir.replace(/\\\\/g, "/")}`; routes.push(routePath); } for (const entry of entries) { if (!entry.isDirectory()) continue; if (["api", "components"].includes(entry.name)) continue; if (entry.name.startsWith("(")) continue; if (entry.name.startsWith("_")) continue; if (entry.name === "node_modules") continue; await walk(path.join(relativeDir, entry.name)); } } await walk(""); routes.sort((a, b) => { if (a === "/" && b !== "/") return -1; if (b === "/" && a !== "/") return 1; return a.localeCompare(b); }); return routes; } export default async function Pages() { const routes = await collectRoutes(APP_DIR); return (

모든 페이지 링크

); }