Skip to content

Commit 5a8d014

Browse files
committed
ui(navigation): revamp not found page with dynamic context and actions
1 parent ea60072 commit 5a8d014

1 file changed

Lines changed: 88 additions & 15 deletions

File tree

src/components/not-found.tsx

Lines changed: 88 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,110 @@
1+
"use client"
2+
13
import Link from "next/link"
2-
import { ArrowRightIcon } from "lucide-react"
4+
import { usePathname } from "next/navigation"
5+
import {
6+
ArrowLeftIcon,
7+
FileTextIcon,
8+
FolderGit2Icon,
9+
HomeIcon,
10+
} from "lucide-react"
311

412
import { cn } from "@/lib/utils"
513
import { Button } from "@/components/ui/button"
614

715
import { WistantMark } from "./wistant-mark"
816

917
export function NotFound({ className }: { className?: string }) {
18+
const pathname = usePathname() || ""
19+
20+
const isBlog = pathname.startsWith("/blog")
21+
const isProject = pathname.startsWith("/projects")
22+
const isCert = pathname.startsWith("/certifications")
23+
24+
const handleGoBack = () => {
25+
if (typeof window !== "undefined") {
26+
window.history.back()
27+
}
28+
}
29+
1030
return (
1131
<div
1232
className={cn(
13-
"flex h-[calc(100svh-5.5rem)] flex-col items-center justify-center px-4 text-center",
33+
"flex h-[calc(100svh-5.5rem)] flex-col items-center justify-center px-4 text-center select-none",
1434
className
1535
)}
1636
>
1737
<div className="relative mb-6 flex items-center justify-center">
18-
<WistantMark className="h-20 w-auto animate-pulse text-muted-foreground/30" />
38+
<div className="animate-bounce duration-3000">
39+
<WistantMark className="h-20 w-auto text-foreground/80 transition-transform duration-500 hover:scale-110 hover:rotate-6 dark:text-foreground/90" />
40+
</div>
1941
</div>
2042

21-
<h1 className="text-8xl font-bold tracking-tighter text-foreground/90 tabular-nums">
22-
404
23-
</h1>
43+
<div className="screen-line-top screen-line-bottom w-full max-w-md space-y-4 px-4 py-6">
44+
<h1 className="text-6xl font-bold tracking-tighter text-foreground/90 tabular-nums">
45+
404
46+
</h1>
2447

25-
<p className="mt-2 mb-8 max-w-xs text-sm text-muted-foreground">
26-
The page you are looking for does not exist or has been moved.
27-
</p>
48+
<div className="space-y-2">
49+
<h2 className="text-lg font-semibold tracking-tight">
50+
{isBlog
51+
? "Blog post not found"
52+
: isProject
53+
? "Project not found"
54+
: isCert
55+
? "Certification not found"
56+
: "Page not found"}
57+
</h2>
58+
<p className="mx-auto max-w-xs text-sm text-muted-foreground">
59+
{isBlog
60+
? "This post doesn't exist or has been archived. You can explore other articles below."
61+
: isProject
62+
? "This case study doesn't exist or is currently being updated. Check out other projects."
63+
: isCert
64+
? "This certification review is not available yet. We are preparing more credentials."
65+
: "The page you are looking for does not exist, has been moved, or is still under construction."}
66+
</p>
67+
</div>
68+
</div>
69+
70+
<div className="mt-8 flex w-full max-w-xs flex-col gap-3">
71+
<Button onClick={handleGoBack} variant="outline" className="gap-2">
72+
<ArrowLeftIcon className="size-4" />
73+
<span>Go Back</span>
74+
</Button>
2875

29-
<Button asChild className="group">
30-
<Link href="/">
31-
Go to Home
32-
<ArrowRightIcon className="transition-transform group-hover:translate-x-1" />
33-
</Link>
34-
</Button>
76+
<div className="flex gap-2">
77+
<Button asChild className="flex-1 gap-1.5" variant="secondary">
78+
<Link href="/">
79+
<HomeIcon className="size-3.5" />
80+
<span>Home</span>
81+
</Link>
82+
</Button>
83+
84+
{isBlog ? (
85+
<Button asChild className="flex-1 gap-1.5" variant="secondary">
86+
<Link href="/blog">
87+
<FileTextIcon className="size-3.5" />
88+
<span>Other Blogs</span>
89+
</Link>
90+
</Button>
91+
) : isProject ? (
92+
<Button asChild className="flex-1 gap-1.5" variant="secondary">
93+
<Link href="/projects">
94+
<FolderGit2Icon className="size-3.5" />
95+
<span>Projects</span>
96+
</Link>
97+
</Button>
98+
) : (
99+
<Button asChild className="flex-1 gap-1.5" variant="secondary">
100+
<Link href="/blog">
101+
<FileTextIcon className="size-3.5" />
102+
<span>Blog</span>
103+
</Link>
104+
</Button>
105+
)}
106+
</div>
107+
</div>
35108
</div>
36109
)
37110
}

0 commit comments

Comments
 (0)