Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

888 B
Raw Blame
import { Button, type ButtonProps } from '@umami/react-zen';
import type { ReactNode } from 'react';
import Link from '@/components/common/Link';
import { useLocale } from '@/components/hooks';

export interface LinkButtonProps extends ButtonProps {
  href: string;
  target?: string;
  scroll?: boolean;
  variant?: any;
  prefetch?: boolean;
  asAnchor?: boolean;
  children?: ReactNode;
}

export function LinkButton({
  href,
  variant,
  scroll = true,
  target,
  prefetch,
  children,
  asAnchor,
  ...props
}: LinkButtonProps) {
  const { dir } = useLocale();

  const linkElement = asAnchor ? (
    <a href={href} target={target}>
      {children}
    </a>
  ) : (
    <Link href={href} dir={dir} scroll={scroll} target={target} prefetch={prefetch}>
      {children}
    </Link>
  );

  return <Button {...props} variant={variant} nativeButton={false} render={linkElement} />;
}