Skip to content

Commit

Permalink
Fix external links detecting on card component
Browse files Browse the repository at this point in the history
  • Loading branch information
fuma-nama committed May 16, 2023
1 parent 9e00181 commit 03db9a9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/mdx/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ export function Card({
title: string;
description: string;
}) {
const external = !href.startsWith("/");

return (
<Link
href={href}
target="_blank"
rel="noreferrer"
target={external ? "_blank" : "_self"}
rel={external ? "noreferrer" : ""}
className="rounded-xl p-4 border-[1px] flex flex-col gap-2 hover:border-purple-400"
>
<h3 className="text-foreground font-semibold">{title}</h3>
Expand Down

0 comments on commit 03db9a9

Please sign in to comment.