Files
umami/src/components/hooks/useTeamUrl.ts
2025-03-20 23:12:56 -07:00

13 lines
328 B
TypeScript

import { usePathname } from 'next/navigation';
export function useTeamUrl() {
const pathname = usePathname();
const [, teamId] = pathname.match(/^\/teams\/([a-f0-9-]+)/) || [];
function renderTeamUrl(url: string) {
return teamId ? `/teams/${teamId}${url}` : url;
}
return { teamId, renderTeamUrl, pathname };
}