content(resources): add link to GitHub

This commit is contained in:
Jean-Philippe Sirois
2019-09-17 01:58:45 -04:00
parent 94f8c5317d
commit 568977a4ee
5 changed files with 29 additions and 4 deletions
+11 -1
View File
@@ -7,5 +7,15 @@ export function ResourcesLink({
}: PropsWithChildren<{
to: string
}>) {
return <SC.ResourcesLinkWrapper to={to}>{children}</SC.ResourcesLinkWrapper>
if (!to.match(/^(https?:\/\/)/)) {
return (
<SC.ResourcesLinkInternal to={to}>{children}</SC.ResourcesLinkInternal>
)
}
return (
<SC.ResourcesLinkExternal href={to} target="_blank">
{children}
</SC.ResourcesLinkExternal>
)
}
+10 -2
View File
@@ -1,7 +1,7 @@
import { Link } from "gatsby"
import styled from "styled-components"
import styled, { css } from "styled-components"
export const ResourcesLinkWrapper = styled(Link)`
const linkStyle = css`
color: #0090d8;
font-weight: 700;
border-bottom: 2px solid;
@@ -14,3 +14,11 @@ export const ResourcesLinkWrapper = styled(Link)`
transition: none;
}
`
export const ResourcesLinkInternal = styled(Link)`
${linkStyle}
`
export const ResourcesLinkExternal = styled.a`
${linkStyle}
`