initial to gitea

This commit is contained in:
2025-02-23 10:43:08 +07:00
commit d6e3946296
183 changed files with 22627 additions and 0 deletions

38
components/anchor.tsx Normal file
View File

@@ -0,0 +1,38 @@
"use client";
import { cn } from "@/lib/utils";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { ComponentProps } from "react";
type AnchorProps = ComponentProps<typeof Link> & {
absolute?: boolean;
activeClassName?: string;
disabled?: boolean;
};
export default function Anchor({
absolute,
className = "",
activeClassName = "",
disabled,
children,
...props
}: AnchorProps) {
const path = usePathname();
let isMatch = absolute
? props.href.toString().split("/")[1] == path.split("/")[1]
: path === props.href;
if (props.href.toString().includes("http")) isMatch = false;
if (disabled)
return (
<div className={cn(className, "cursor-not-allowed")}>{children}</div>
);
return (
<Link className={cn(className, isMatch && activeClassName)} {...props}>
{children}
</Link>
);
}