mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-16 14:25:22 +00:00
move to link
This commit is contained in:
parent
1810a773a7
commit
943b914818
1 changed files with 14 additions and 17 deletions
|
|
@ -11,7 +11,9 @@ import Image from "next/image";
|
||||||
import { FileIcon } from "@radix-ui/react-icons";
|
import { FileIcon } from "@radix-ui/react-icons";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { RepositoryQuery } from "@/lib/types";
|
import { RepositoryQuery } from "@/lib/types";
|
||||||
import { useBrowseNavigation } from "../../browse/hooks/useBrowseNavigation";
|
import { getBrowsePath } from "../../browse/hooks/useBrowseNavigation";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { useDomain } from "@/hooks/useDomain";
|
||||||
|
|
||||||
interface RepositoryCarouselProps {
|
interface RepositoryCarouselProps {
|
||||||
repos: RepositoryQuery[];
|
repos: RepositoryQuery[];
|
||||||
|
|
@ -57,9 +59,8 @@ interface RepositoryBadgeProps {
|
||||||
const RepositoryBadge = ({
|
const RepositoryBadge = ({
|
||||||
repo
|
repo
|
||||||
}: RepositoryBadgeProps) => {
|
}: RepositoryBadgeProps) => {
|
||||||
const { navigateToPath } = useBrowseNavigation();
|
const domain = useDomain();
|
||||||
|
const { repoIcon, displayName } = (() => {
|
||||||
const { repoIcon, displayName, repoLink } = (() => {
|
|
||||||
const info = getCodeHostInfoForRepo({
|
const info = getCodeHostInfoForRepo({
|
||||||
codeHostType: repo.codeHostType,
|
codeHostType: repo.codeHostType,
|
||||||
name: repo.repoName,
|
name: repo.repoName,
|
||||||
|
|
@ -75,34 +76,30 @@ const RepositoryBadge = ({
|
||||||
className={`w-4 h-4 ${info.iconClassName}`}
|
className={`w-4 h-4 ${info.iconClassName}`}
|
||||||
/>,
|
/>,
|
||||||
displayName: info.displayName,
|
displayName: info.displayName,
|
||||||
repoLink: info.repoLink,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
repoIcon: <FileIcon className="w-4 h-4" />,
|
repoIcon: <FileIcon className="w-4 h-4" />,
|
||||||
displayName: repo.repoName,
|
displayName: repo.repoName,
|
||||||
repoLink: undefined,
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<Link
|
||||||
onClick={() => {
|
href={getBrowsePath({
|
||||||
navigateToPath({
|
|
||||||
repoName: repo.repoName,
|
repoName: repo.repoName,
|
||||||
path: '/',
|
path: '/',
|
||||||
pathType: 'tree',
|
pathType: 'tree',
|
||||||
});
|
domain
|
||||||
}}
|
|
||||||
className={clsx("flex flex-row items-center gap-2 border rounded-md p-2 text-clip", {
|
|
||||||
"cursor-pointer": repoLink !== undefined,
|
|
||||||
})}
|
})}
|
||||||
|
|
||||||
|
className={clsx("flex flex-row items-center gap-2 border rounded-md p-2 text-clip")}
|
||||||
>
|
>
|
||||||
{repoIcon}
|
{repoIcon}
|
||||||
<span className="text-sm font-mono">
|
<span className="text-sm font-mono">
|
||||||
{displayName}
|
{displayName}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</Link>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue