forked from www/www-new
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
677 B
28 lines
677 B
import NextLink, { LinkProps as NextLinkProps } from "next/link";
|
|
import React from "react";
|
|
|
|
import styles from "./Link.module.css";
|
|
|
|
type Props = Omit<NextLinkProps, "href"> & { href: string };
|
|
|
|
export const Link: React.FC<Props> = (props) => {
|
|
const { children, ...otherProps } = props;
|
|
const { href } = otherProps;
|
|
|
|
const isExternal = href.includes("http://") || href.includes("https://");
|
|
|
|
return isExternal ? (
|
|
<a
|
|
className={styles.link}
|
|
href={href}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
>
|
|
{children}
|
|
</a>
|
|
) : (
|
|
<NextLink {...otherProps}>
|
|
<a className={styles.link}>{children}</a>
|
|
</NextLink>
|
|
);
|
|
};
|
|
|