diff --git a/src/App.tsx b/src/App.tsx index 2e6032b..24a3c02 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ -import React from 'react'; -import { Routes, Route } from 'react-router-dom'; +import React, { useEffect } from 'react'; +import { Routes, Route, useLocation } from 'react-router-dom'; import Navbar from './components/Navbar'; import HeroSection from './components/HeroSection'; import StatisticsSection from './components/StatisticsSection'; @@ -14,17 +14,42 @@ import MatrixBackground from './components/MatrixBackground'; import './App.css'; // HomePage component -const HomePage: React.FC = () => ( -
- -
- -
- -
-); +const HomePage: React.FC = () => { + const location = useLocation(); + + useEffect(() => { + if (location.hash) { + const element = document.getElementById(location.hash.substring(1)); + if (element) { + element.scrollIntoView({ behavior: 'smooth' }); + } + } + }, [location]); + + return ( +
+ +
+ +
+ +
+ ); +}; function App() { + const location = useLocation(); + + useEffect(() => { + const segment = location.hash; + if (segment) { + const element = document.getElementById(segment.replace('#', '')); + if (element) { + element.scrollIntoView({ behavior: 'smooth', block: 'start' }); + } + } + }, [location]); + return (