"use client";
import { useEffect, useState } from "react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { Home, ArrowLeft, Search } from "lucide-react";
export default function NotFound() {
const [mounted, setMounted] = useState(false);
const [input, setInput] = useState("");
const router = useRouter();
useEffect(() => {
setMounted(true);
}, []);
// In tests, avoid next/dynamic loadable timing and render a stable fallback
if (process.env.NODE_ENV === "test") {
return (
Oops! The page you're looking for doesn't exist.
);
}
if (!mounted) {
return (
);
}
const handleCommand = (cmd: string) => {
const command = cmd.toLowerCase().trim();
if (command === 'home' || command === 'cd ~' || command === 'cd /') {
router.push('/');
} else if (command === 'back' || command === 'cd ..') {
router.back();
} else if (command === 'search') {
router.push('/projects');
}
};
return (
{/* Terminal-style 404 */}
{/* Terminal Header */}
{/* Terminal Body */}
$ cd {mounted ? window.location.pathname : '/unknown'}
✗
Error: ENOENT: no such file or directory
{`
██╗ ██╗ ██████╗ ██╗ ██╗
██║ ██║██╔═████╗██║ ██║
███████║██║██╔██║███████║
╚════██║████╔╝██║╚════██║
██║╚██████╔╝ ██║
╚═╝ ╚═════╝ ╚═╝
`}
The page you're looking for seems to have wandered off.
Perhaps it never existed, or maybe it's on a coffee break.
Available commands:
→ home - Return to homepage
→ back - Go back to previous page
→ search - Search the website
{/* Interactive Command Line */}
$
setInput(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter') {
handleCommand(input);
setInput('');
}
}}
placeholder="Type a command..."
className="flex-1 bg-transparent text-[#faf8f3] outline-none placeholder:text-[#795548] font-mono"
autoFocus
/>
{/* Quick Action Buttons */}
Home
Explore Projects
);
}