Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 51d3139

Browse files
authored
fix: make external links open in new tabs (#114)
introduce an external link component to facilitate them always opening in new tabs introduce rel=noreferrer to prevent javascript hijacking by target tabs Closes #107
1 parent 062efb1 commit 51d3139

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/components/ExternalLink.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Link from "next/link";
2+
3+
export default function ExternalLink({ href, children, ...rest }) {
4+
return <Link target={"_blank"} rel={"noreferrer"} href={href} {...rest}>{ children }</Link>;
5+
}

src/components/Footer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import data from "@/config/app.json";
2-
import Link from "next/link";
2+
import ExternalLink from "@/components/ExternalLink";
33

44
export default function Footer() {
55
const githubUrl = "https://github.com/EddieHubCommunity/CreatorsRegistry";
@@ -11,7 +11,7 @@ export default function Footer() {
1111
&copy; {new Date().getFullYear()} EddieHub All rights reserved | v
1212
{data.version}
1313
</div>
14-
<Link href={githubUrl}>{githubUrl}</Link>
14+
<ExternalLink href={githubUrl}>{githubUrl}</ExternalLink>
1515
</div>
1616
</footer>
1717
);

src/components/list/Item.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { ChevronRightIcon } from "@heroicons/react/20/solid";
22
import Image from "next/image";
3-
import Link from "next/link";
43
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
54

65
import Badge from "@/components/Badge";
76
import socialIcon from "@/config/socialIcon";
7+
import ExternalLink from "@/components/ExternalLink";
88

99
export default function Item({ data }) {
1010
return (
@@ -33,10 +33,10 @@ export default function Item({ data }) {
3333
)}
3434
<div className="min-w-0 flex-auto">
3535
<p className="text-sm font-semibold leading-6 text-gray-900">
36-
<Link href={data.url}>
36+
<ExternalLink href={data.url}>
3737
<span className="absolute inset-x-0 -top-px bottom-0" />
3838
{data.urlText}
39-
</Link>
39+
</ExternalLink>
4040
</p>
4141
<p className="mt-1 flex text-xs leading-5 text-gray-500">
4242
{data.description}

0 commit comments

Comments
 (0)