diff --git a/src/App.jsx b/src/App.jsx index 0569b06..d47fc2a 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -7,6 +7,7 @@ import Hero from './components/Hero'; import About from './components/About'; import Projects from './components/Projects'; import Contact from './components/Contact'; +import NotFound from './components/NotFound'; import Footer from './components/Footer'; import styles from './App.module.scss'; @@ -27,18 +28,15 @@ export default function App() { const [displayedSection, setDisplayedSection] = useState(activeSection); const timerRef = useRef(null); + const path = location.pathname.substring(1) || 'home'; + const notFound = !Object.keys(SECTIONS).includes(path); + // Sync URL path with activeSection useEffect(() => { - const path = location.pathname.substring(1) || 'home'; - if (Object.keys(SECTIONS).includes(path)) { - if (path !== activeSection) { - setActiveSection(path); - } - } else { - // Invalid path, redirect to home - navigate('/'); + if (!notFound && path !== activeSection) { + setActiveSection(path); } - }, [location.pathname, activeSection, setActiveSection, navigate]); + }, [location.pathname, activeSection, setActiveSection, navigate, path, notFound]); useEffect(() => { if (theme === 'light') { @@ -59,6 +57,18 @@ export default function App() { const isExiting = activeSection !== displayedSection; const Section = SECTIONS[displayedSection] ?? Hero; + if (notFound) { + return ( + <> + + + + + + > + ); + } + return ( <> diff --git a/src/components/NotFound.jsx b/src/components/NotFound.jsx new file mode 100644 index 0000000..5fb69de --- /dev/null +++ b/src/components/NotFound.jsx @@ -0,0 +1,15 @@ +import styles from '../styles/components/NotFound.module.scss'; + +export default function NotFound() { + return ( + + + + + + Page Not Found + The page you're looking for doesn't exist. + + + ); +} diff --git a/src/styles/components/NotFound.module.scss b/src/styles/components/NotFound.module.scss new file mode 100644 index 0000000..21c4c6a --- /dev/null +++ b/src/styles/components/NotFound.module.scss @@ -0,0 +1,39 @@ +@use '../variables' as *; + +.notFound { + padding: $space-24 $space-6; + min-height: 70vh; + display: flex; + align-items: center; + justify-content: center; +} + +.inner { + max-width: $max-width; + margin: 0 auto; + text-align: center; +} + +.imageContainer { + margin-bottom: $space-8; +} + +.image { + max-width: 100%; + height: auto; + border-radius: $radius-lg; + box-shadow: 0 0 30px rgb(var(--color-primary-mid) / 0.2); +} + +.title { + font-size: $text-4xl; + font-weight: 700; + color: $color-text; + margin-bottom: $space-4; +} + +.message { + font-size: $text-lg; + color: $color-text-muted; + line-height: 1.6; +}
The page you're looking for doesn't exist.