Skip to content

Commit 943b914

Browse files
move to link
1 parent 1810a77 commit 943b914

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

packages/web/src/app/[domain]/components/homepage/repositoryCarousel.tsx

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import Image from "next/image";
1111
import { FileIcon } from "@radix-ui/react-icons";
1212
import clsx from "clsx";
1313
import { RepositoryQuery } from "@/lib/types";
14-
import { useBrowseNavigation } from "../../browse/hooks/useBrowseNavigation";
14+
import { getBrowsePath } from "../../browse/hooks/useBrowseNavigation";
15+
import Link from "next/link";
16+
import { useDomain } from "@/hooks/useDomain";
1517

1618
interface RepositoryCarouselProps {
1719
repos: RepositoryQuery[];
@@ -57,9 +59,8 @@ interface RepositoryBadgeProps {
5759
const RepositoryBadge = ({
5860
repo
5961
}: RepositoryBadgeProps) => {
60-
const { navigateToPath } = useBrowseNavigation();
61-
62-
const { repoIcon, displayName, repoLink } = (() => {
62+
const domain = useDomain();
63+
const { repoIcon, displayName } = (() => {
6364
const info = getCodeHostInfoForRepo({
6465
codeHostType: repo.codeHostType,
6566
name: repo.repoName,
@@ -75,34 +76,30 @@ const RepositoryBadge = ({
7576
className={`w-4 h-4 ${info.iconClassName}`}
7677
/>,
7778
displayName: info.displayName,
78-
repoLink: info.repoLink,
7979
}
8080
}
8181

8282
return {
8383
repoIcon: <FileIcon className="w-4 h-4" />,
8484
displayName: repo.repoName,
85-
repoLink: undefined,
8685
}
8786
})();
8887

8988
return (
90-
<div
91-
onClick={() => {
92-
navigateToPath({
93-
repoName: repo.repoName,
94-
path: '/',
95-
pathType: 'tree',
96-
});
97-
}}
98-
className={clsx("flex flex-row items-center gap-2 border rounded-md p-2 text-clip", {
99-
"cursor-pointer": repoLink !== undefined,
89+
<Link
90+
href={getBrowsePath({
91+
repoName: repo.repoName,
92+
path: '/',
93+
pathType: 'tree',
94+
domain
10095
})}
96+
97+
className={clsx("flex flex-row items-center gap-2 border rounded-md p-2 text-clip")}
10198
>
10299
{repoIcon}
103100
<span className="text-sm font-mono">
104101
{displayName}
105102
</span>
106-
</div>
103+
</Link>
107104
)
108105
}

0 commit comments

Comments
 (0)