Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
fix: open non-origin links on a new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioramos committed Aug 31, 2023
1 parent 9d3010d commit 4ee5533
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
14 changes: 13 additions & 1 deletion src/components/TemplatedCaseStudy/MarkdownRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,19 @@ const MarkdownRenderer = ({ source }) => (
ol: (props) => <OrderedList {...props} />,
ul: (props) => <UnorderedList {...props} />,
li: (props) => <ListItem {...props} />,
a: (props) => <A {...props} />,
a({ href, ...props }) {
return (
<A
target={
new URL(href).origin === window.location.origin
? 'self'
: '_blank'
}
href={href}
{...props}
/>
);
},
strong: (props) => <Strong {...props} />,
}}
>
Expand Down
15 changes: 4 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12794,17 +12794,10 @@ __metadata:
languageName: node
linkType: hard

"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001109, caniuse-lite@npm:^1.0.30001280, caniuse-lite@npm:^1.0.30001286, caniuse-lite@npm:^1.0.30001332, caniuse-lite@npm:^1.0.30001449":
version: 1.0.30001450
resolution: "caniuse-lite@npm:1.0.30001450"
checksum: 511b360bfc907b2e437699364cf96b83507bc45043926450056642332bcd6f65a1e72540c828534ae15e0ac906e3e9af46cb2bb84458dd580bc31478e9dce282
languageName: node
linkType: hard

"caniuse-lite@npm:^1.0.30001464, caniuse-lite@npm:^1.0.30001503":
version: 1.0.30001517
resolution: "caniuse-lite@npm:1.0.30001517"
checksum: e4e87436ae1c4408cf4438aac22902b31eb03f3f5bad7f33bc518d12ffb35f3fd9395ccf7efc608ee046f90ce324ec6f7f26f8a8172b8c43c26a06ecee612a29
"caniuse-lite@npm:^1.0.0, caniuse-lite@npm:^1.0.30001109, caniuse-lite@npm:^1.0.30001280, caniuse-lite@npm:^1.0.30001286, caniuse-lite@npm:^1.0.30001332, caniuse-lite@npm:^1.0.30001449, caniuse-lite@npm:^1.0.30001464, caniuse-lite@npm:^1.0.30001503":
version: 1.0.30001525
resolution: "caniuse-lite@npm:1.0.30001525"
checksum: a0d190c185b8e1220dbc72e42f310633059aa175ca3396eb781b249ac3da6c62b30cb8efc5fa24d632cb938f58d90b0c7772d1c9942b6643cf418c27c2cb8632
languageName: node
linkType: hard

Expand Down

0 comments on commit 4ee5533

Please sign in to comment.