1- import { AlignLeftIcon } from 'lucide-react'
1+ import { AlignLeftIcon , ArrowRight } from 'lucide-react'
22import { useCallback , useRef , useState } from 'react'
33
44import { MDX } from './components'
@@ -7,11 +7,22 @@ import { MobileTableOfContents } from './components/MobileTableOfContents'
77import { Sidebar } from './components/Sidebar'
88import { TableOfContents } from './components/TableOfContents'
99import routes from './routes'
10+ import { getRandomKaomoji } from './utils/kaomoji'
1011
1112function App ( { url } : { url ?: string } ) {
1213 const [ currentPath , setCurrentPath ] = useState ( url || '/' )
1314 const [ isSidebarOpen , setIsSidebarOpen ] = useState ( false )
14- const matchedRoute = routes . find ( ( route ) => route . path === currentPath )
15+ const matchedRoute = routes . find ( ( route ) => {
16+ const normalizedCurrentPath =
17+ currentPath . endsWith ( '/' ) && currentPath !== '/'
18+ ? currentPath . slice ( 0 , - 1 )
19+ : currentPath
20+ const normalizedRoutePath =
21+ route . path . endsWith ( '/' ) && route . path !== '/'
22+ ? route . path . slice ( 0 , - 1 )
23+ : route . path
24+ return normalizedRoutePath === normalizedCurrentPath
25+ } )
1526 const mainContentRef = useRef < HTMLDivElement > ( null )
1627
1728 const handleScrollMainContent = ( top : number ) => {
@@ -93,17 +104,18 @@ function App({ url }: { url?: string }) {
93104 </ div >
94105 </ div >
95106
96- < div className = "bg-background-secondary border-separator-opaque mx-4 mt-16 rounded-xl border p-8 text-center shadow-sm lg:mt-0" >
97- < h1 className = "text-text-primary mb-3 text-3xl font-semibold" >
98- 404
99- </ h1 >
107+ < div className = "mx-4 mt-16 rounded-xl p-8 text-center lg:mt-0" >
108+ < div className = "mb-6 flex items-center justify-center text-4xl" >
109+ { getRandomKaomoji ( ) }
110+ </ div >
111+ < h1 className = "mb-1 text-3xl font-semibold" > 404</ h1 >
100112 < p className = "text-text-secondary text-lg" > Page not found</ p >
101113 < button
102114 onClick = { ( ) => handleNavigate ( '/' ) }
103- className = "bg-accent mt-6 rounded-lg px-4 py-2 text-white transition-opacity hover:opacity-90"
115+ className = "bg-accent mt-6 rounded-2xl px-4 py-2 text-white transition-opacity hover:opacity-90"
104116 type = "button"
105117 >
106- Return Home
118+ Return Home < ArrowRight className = "inline-block h-4 w-4" />
107119 </ button >
108120 </ div >
109121
0 commit comments