Extract section id from url
Unanswered
Transvaal lion posted this in #help-forum
Transvaal lionOP
I'm trying to change the navigation style based on whether the user is visiting the section of the current page by clicking the navigation bar's link.
Meaning that my url changes to http://blabla.com/#about
Is there a way to extract
Meaning that my url changes to http://blabla.com/#about
Is there a way to extract
#about or #projects somehow to change my tailwind styles accordingly? I tried useParams and useRouter but I can't capture what I need.15 Replies
Dunker
usePathname or location.pathname.split("/")[1]Transvaal lionOP
usePathname only gives me the root
/Dunker
location.href.split("/")[3]"#about"Transvaal lionOP
where do you get location from? 👀
Dunker
JS lib ? 😄
Transvaal lionOP
so you're using a client component?
I'll check it out thanks â¤ï¸
Dunker
are you setting color at client component
Transvaal lionOP
on the server component and yeah
tailwind
I'll just convert it's no biggie
Dunker
okay,if you need more help tell me
✅
Transvaal lionOP
all good cheers 😄