feat(link): init component

This commit is contained in:
2021-01-18 21:40:21 +00:00
parent 7627876968
commit 006a51366a

18
src/components/link.js Normal file
View File

@@ -0,0 +1,18 @@
import React from "react";
import styled from "styled-components";
import { Link as GatsbyLink } from "gatsby";
const StyledLink = styled.a`
font-size: ${props => `var(--font-size-${props.size})`};
color: ${props => `var(--theme-color-${props.color})`};
text-decoration: none;
`;
export default function Link({ children, to, ...other }) {
const isInternal = /^\/(?!\/)/.test(to);
return (
<StyledLink href={to} as={isInternal ? GatsbyLink : "a"} {...other}>
{children}
</StyledLink>
);
}