Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
fix(Link): strip target&rel from wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
CanRau committed Dec 15, 2019
1 parent 9648414 commit 85016d0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ const isFqdn = x => !/^\/(?!\/)/.test(x)
const isAnchor = x => /^#/.test(x)

export const Link = React.forwardRef(
({ to, href, as, ext, variant = `default`, children, ...props }, ref) => {
(
{ to, href, as, ext, variant = `default`, target, rel, children, ...props },
ref
) => {
const url = to || href
const isExt = ext || isFqdn(url)
const Tag = as ? as : isExt ? `a` : GatsbyLink
Expand All @@ -34,8 +37,8 @@ export const Link = React.forwardRef(
}),
...(isExt &&
!isAnchor(url) && {
target: `_blank`,
rel: `nofollow noopener noreferrer`,
target: target || `_blank`,
rel: rel || `nofollow noopener noreferrer`,
}),
}
return (
Expand All @@ -51,6 +54,8 @@ Link.propTypes = {
to: PropTypes.string,
href: PropTypes.string,
variant: PropTypes.string,
target: PropTypes.string,
rel: PropTypes.string,
as: PropTypes.string,
ext: PropTypes.bool,
}
Expand Down

0 comments on commit 85016d0

Please sign in to comment.