parent
426c81360e
commit
078276efa7
@ -0,0 +1,10 @@ |
||||
.link { |
||||
color: var(--blue-2); |
||||
transition-duration: 0.3s; |
||||
text-decoration: none; |
||||
white-space: normal; |
||||
} |
||||
|
||||
.link:hover { |
||||
color: var(--teal-2); |
||||
} |
@ -0,0 +1,28 @@ |
||||
import React from "react"; |
||||
import styles from "./Link.module.css"; |
||||
import NextLink from "next/link"; |
||||
import { LinkProps as NextLinkProps } from "next/link"; |
||||
|
||||
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> |
||||
); |
||||
}; |
Loading…
Reference in new issue