diff --git a/src/components/ui/TerminalPath.astro b/src/components/ui/TerminalPath.astro index ed7e85d..242dc55 100644 --- a/src/components/ui/TerminalPath.astro +++ b/src/components/ui/TerminalPath.astro @@ -1,15 +1,31 @@ --- +interface Props { + command?: "cat" | "ls" | "exit"; + value?: string; +} + const pathname = Astro.url.pathname; -const cleanPath = pathname.replace(/^\/|\/$/g, ""); +const cleanPath = pathname.replace(/^\/+|\/+$/g, ""); +const isDirectory = ["projects", "posts", "games"].includes(cleanPath); -const filePath = cleanPath === "" ? "home.hy" : `${cleanPath}.hy`; +const command = Astro.props.command ?? (isDirectory ? "ls" : "cat"); +const value = + Astro.props.value ?? + (isDirectory + ? `${cleanPath}/` + : cleanPath === "" + ? "home.hy" + : `${cleanPath}.hy`); --- -