sourcebot/packages/web/src/app/[domain]/browse/hooks/useBrowseNavigation.ts
Brendan Kellam 4ebe4e0475
Some checks failed
Publish to ghcr / build (linux/amd64, blacksmith-4vcpu-ubuntu-2404) (push) Has been cancelled
Publish to ghcr / build (linux/arm64, blacksmith-8vcpu-ubuntu-2204-arm) (push) Has been cancelled
Publish to ghcr / merge (push) Has been cancelled
chore(worker,web): Repo indexing stability improvements + perf improvements to web (#563)
2025-10-18 16:31:22 -07:00

36 lines
No EOL
860 B
TypeScript

'use client';
import { useRouter } from "next/navigation";
import { useDomain } from "@/hooks/useDomain";
import { useCallback } from "react";
import { getBrowsePath, GetBrowsePathProps } from "./utils";
export const useBrowseNavigation = () => {
const router = useRouter();
const domain = useDomain();
const navigateToPath = useCallback(({
repoName,
revisionName = 'HEAD',
path,
pathType,
highlightRange,
setBrowseState,
}: Omit<GetBrowsePathProps, 'domain'>) => {
const browsePath = getBrowsePath({
repoName,
revisionName,
path,
pathType,
highlightRange,
setBrowseState,
domain,
});
router.push(browsePath);
}, [domain, router]);
return {
navigateToPath,
};
};