I am making a navbar in which 3 options are available; In this the home button should scroll to top if and also want to redirect to homepage if in another page. The another button should also do the same but should scroll to the section. This is the navbar I tried, but in this either it redirects or it scrolls, both not working together, I am also using the @mui/material in this :
<Stack className='nav-items' direction='row'>
<Link to='/' className='stack-home'>Home</Link>
<a href='#exercises'>Exercises</a>
<a href='#videos'>Videos</a>
</Stack>
The exercise section is in home page, when I click on it I want it to scroll to the section & also want to redirect to this page if in another page. the tag will help to redirect and the tag helps to scroll, I want to implement both in one button/element.
Also I want the 3rd item(Videos) to show up when in the second page only. How will I do it?