fix(market): a trailing slash is not a different page

`trailingSlash` made the router report `/support/` for a link written
`/support`, so comparing the two raw strings matched nothing and every item in
the support nav read inactive on its own page.

One function normalises both sides, and it matches exactly rather than by
prefix. Every link in both navs is a leaf, and a prefix match lights the wrong
ones — `/support` under `/support/projects`, and `/launch` under `/launches`.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
2026-08-29 18:19:01 -07:00
co-authored by Hanzo Dev
parent cb6db81c52
commit c53de77512
3 changed files with 19 additions and 2 deletions
+2 -1
View File
@@ -5,6 +5,7 @@ import { usePathname } from 'next/navigation'
import type { ReactNode } from 'react'
import { Footer } from '@/components/Footer'
import { Header } from '@/components/Header'
import { here } from '@/lib/links'
import { cn } from '@/lib/utils'
const PAGES = [
@@ -31,7 +32,7 @@ export default function SupportLayout({ children }: { children: ReactNode }) {
href={p.href}
className={cn(
'no-underline transition-colors hover:text-foreground',
pathname === p.href ? 'font-semibold text-foreground' : 'text-muted-foreground',
here(pathname, p.href) ? 'font-semibold text-foreground' : 'text-muted-foreground',
)}
>
{p.label}
+2 -1
View File
@@ -7,6 +7,7 @@ import { useAccount, useConnect, useDisconnect } from 'wagmi'
import { injected } from 'wagmi/connectors'
import { Button } from '@/components/ui/button'
import { useChain } from '@/hooks/chain'
import { here } from '@/lib/links'
import { cn, shortenAddress } from '@/lib/utils'
// The chrome is `AppNav` from @luxfi/ui — brand, org switcher, links, settings
@@ -81,7 +82,7 @@ export function Header() {
return (
<AppNav
brand="Lux Market"
links={LINKS.map((l) => ({ ...l, active: pathname === l.href || pathname.startsWith(`${l.href}/`) }))}
links={LINKS.map((l) => ({ ...l, active: here(pathname, l.href) }))}
>
<ChainSelector />
{/* wagmi mounts only once the registry has named the chains it can reach. */}
+15
View File
@@ -12,3 +12,18 @@ export const collection = (chain: Chain, address: string) =>
export const item = (chain: Chain, address: string, id: string) =>
`/item?chain=${chain.slug}&address=${address}&id=${id}`
/**
* Is `href` the page being read?
*
* `trailingSlash` makes the router report `/support/` for a link written
* `/support`, so comparing the raw strings matched nothing and every nav item
* read inactive. Both sides lose the trailing slash first.
*
* The match is exact, not by prefix. Every link in both navs is a leaf, and a
* prefix match lights the wrong ones: `/support` under `/support/projects`, and
* `/launch` under `/launches`.
*/
export const here = (pathname: string, href: string) => trim(pathname) === trim(href)
const trim = (v: string) => (v.length > 1 && v.endsWith('/') ? v.slice(0, -1) : v)