Files

27 lines
512 B
TypeScript

import type { ReactNode } from "react";
import Link from "next/link";
export function SlotLink({
href,
className,
children,
}: {
href?: string;
className?: string;
children: ReactNode;
}) {
if (!href) return <div className={className}>{children}</div>;
if (href.startsWith("/") || href.startsWith("#")) {
return (
<Link href={href} className={className}>
{children}
</Link>
);
}
return (
<a href={href} className={className}>
{children}
</a>
);
}