blob: b7756a72d510f279994fd5bf8234ae8d5c6fcf7a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
/** @jsx jsx */
import { Link as GatsbyLink } from "gatsby";
import isAbsoluteURL from "is-absolute-url";
import { jsx } from "theme-ui";
const linkStyles = { variant: "styles.a" };
function Link({ to = "", href = to, children, ...props }) {
const isAbsoluteLink = isAbsoluteURL(href);
return isAbsoluteLink ||
href.startsWith("http://") ||
href.startsWith("https://") ? (
<a {...props} href={href} sx={linkStyles}>
{children}
</a>
) : (
<GatsbyLink {...props} to={href} activeClassName="active" sx={linkStyles}>
{children}
</GatsbyLink>
);
}
export default Link;
|