refactor(website): use link component with rel

This commit is contained in:
Elian Doran
2025-09-27 14:02:49 +03:00
parent 4e4e65b462
commit c21a9223f5
3 changed files with 35 additions and 17 deletions

View File

@@ -2,25 +2,42 @@ import { ComponentChildren } from "preact";
import Icon from "./Icon";
import "./Button.css";
interface ButtonProps {
interface LinkProps {
className?: string;
href?: string;
openExternally?: boolean;
children: ComponentChildren;
title?: string;
}
interface ButtonProps extends Omit<LinkProps, "children"> {
href?: string;
iconSvg?: string;
text: ComponentChildren;
openExternally?: boolean;
className?: string;
outline?: boolean;
}
export default function Button({ href, iconSvg, openExternally, text, className, outline }: ButtonProps) {
export default function Button({ iconSvg, text, className, outline, ...restProps }: ButtonProps) {
return (
<a
<Link
className={`button ${className} ${outline ? "outline" : ""}`}
href={href}
target={openExternally ? "_blank" : undefined}
rel={openExternally ? "noopener noreferrer" : undefined}
{...restProps}
>
{iconSvg && <><Icon svg={iconSvg} />{" "}</>}
{text}
</Link>
)
}
export function Link({ openExternally, children, ...restProps }: LinkProps) {
return (
<a
{...restProps}
target={openExternally ? "_blank" : undefined}
rel={openExternally ? "noopener noreferrer" : undefined}
>
{children}
</a>
)
}