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

Commit

Permalink
fix: make external links open in new tabs (#114)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Idrinth authored Jul 5, 2024
1 parent 062efb1 commit 51d3139
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/components/ExternalLink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Link from "next/link";

export default function ExternalLink({ href, children, ...rest }) {
return <Link target={"_blank"} rel={"noreferrer"} href={href} {...rest}>{ children }</Link>;
}
4 changes: 2 additions & 2 deletions src/components/Footer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import data from "@/config/app.json";
import Link from "next/link";
import ExternalLink from "@/components/ExternalLink";

export default function Footer() {
const githubUrl = "https://github.com/EddieHubCommunity/CreatorsRegistry";
Expand All @@ -11,7 +11,7 @@ export default function Footer() {
&copy; {new Date().getFullYear()} EddieHub All rights reserved | v
{data.version}
</div>
<Link href={githubUrl}>{githubUrl}</Link>
<ExternalLink href={githubUrl}>{githubUrl}</ExternalLink>
</div>
</footer>
);
Expand Down
6 changes: 3 additions & 3 deletions src/components/list/Item.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ChevronRightIcon } from "@heroicons/react/20/solid";
import Image from "next/image";
import Link from "next/link";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

import Badge from "@/components/Badge";
import socialIcon from "@/config/socialIcon";
import ExternalLink from "@/components/ExternalLink";

export default function Item({ data }) {
return (
Expand Down Expand Up @@ -33,10 +33,10 @@ export default function Item({ data }) {
)}
<div className="min-w-0 flex-auto">
<p className="text-sm font-semibold leading-6 text-gray-900">
<Link href={data.url}>
<ExternalLink href={data.url}>
<span className="absolute inset-x-0 -top-px bottom-0" />
{data.urlText}
</Link>
</ExternalLink>
</p>
<p className="mt-1 flex text-xs leading-5 text-gray-500">
{data.description}
Expand Down

0 comments on commit 51d3139

Please sign in to comment.