fix(Navbar): replace Next.js Link with <a> + onClick for anchor navigation

Next.js Link appends hash instead of replacing it (#a#b#b...). Anchor
links now use native <a> with e.preventDefault(), manual scrollIntoView,
and history.replaceState so only the current hash appears in the URL.
Page routes (/shop etc.) still use Link as before.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marco
2026-06-30 21:45:39 +00:00
parent 8d8674281a
commit 4aa5b924fc
+24 -9
View File
@@ -43,15 +43,30 @@ export function Navbar() {
{/* Nav links */}
<nav className="flex items-center gap-[3rem]">
{navLinks.map((link) => (
<Link
key={link.href}
href={link.href}
className="text-[1.125rem] font-semibold text-[#222221] tracking-[0.01125rem] hover:text-[#f6a701] transition-colors"
>
{link.label}
</Link>
))}
{navLinks.map((link) =>
link.href.startsWith("#") ? (
<a
key={link.href}
href={link.href}
onClick={(e) => {
e.preventDefault();
document.getElementById(link.href.slice(1))?.scrollIntoView({ behavior: "smooth" });
history.replaceState(null, "", link.href);
}}
className="text-[1.125rem] font-semibold text-[#222221] tracking-[0.01125rem] hover:text-[#f6a701] transition-colors cursor-pointer"
>
{link.label}
</a>
) : (
<Link
key={link.href}
href={link.href}
className="text-[1.125rem] font-semibold text-[#222221] tracking-[0.01125rem] hover:text-[#f6a701] transition-colors"
>
{link.label}
</Link>
)
)}
</nav>
{/* CTA buttons */}