import { useLocation } from 'react-router-dom'; interface PondRoute { pondSlug: string | null; pageSlug: string | null; } /** * The sidebar and top bar render outside the routed `` (they wrap * it), so `useParams` cannot see `:pondSlug`/`:pageSlug` — those only exist * on the nested page routes. Parsing the path directly works regardless of * which route matched underneath. */ export function useCurrentPondRoute(): PondRoute { const { pathname } = useLocation(); const match = /^\/p\/([^/]+)(?:\/([^/]+))?/.exec(pathname); return { pondSlug: match?.[1] ?? null, pageSlug: match?.[2] ?? null }; }