Created
December 29, 2018 00:38
-
-
Save donniecode1983/43c8a2dde7cdc8bd3bb9af7493cef4ba to your computer and use it in GitHub Desktop.
gatsby external link component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import GatsbyLink from 'gatsby-link' | |
const Link = props => { | |
if (props.to.startsWith('/')) { | |
return <GatsbyLink {...props} >{props.children}</GatsbyLink> | |
} | |
return ( | |
<a {...props} href={props.to}> | |
{props.children} | |
</a> | |
); | |
}; | |
export default Link |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment