import Link from 'next/link';
import type {ReactNode} from 'react';

type ButtonLinkProps = {
  href: string;
  children: ReactNode;
  variant?: 'primary' | 'secondary' | 'ghost';
  isExternal?: boolean;
};

export function ButtonLink({href, children, variant = 'primary', isExternal = false}: ButtonLinkProps) {
  const className = `button button--${variant}`;

  if (isExternal) {
    return (
      <a className={className} href={href} target="_blank" rel="noreferrer">
        {children}
      </a>
    );
  }

  return (
    <Link className={className} href={href}>
      {children}
    </Link>
  );
}
