Skip to content

Commit 68f0ffa

Browse files
Add external link func to Card component
1 parent c19dc52 commit 68f0ffa

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

components/containers/Card.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ export default function Card({
1111
linkText,
1212
customClass,
1313
}) {
14+
const LinkComponent = link?.startsWith('http') ? (
15+
<a href={link} target='_blank' rel='noopener noreferrer'>
16+
{linkText}
17+
</a>
18+
) : (
19+
<Link href={link}>{linkText}</Link>
20+
);
1421
return (
1522
<div
1623
className={
@@ -32,7 +39,7 @@ export default function Card({
3239
<h2 className={styles.title}>{title}</h2>
3340
<div className={styles.content}>
3441
<p>
35-
{content} {link && <Link href={link}>{linkText}</Link>}
42+
{content} {link && LinkComponent}
3643
</p>
3744
</div>
3845
</div>

0 commit comments

Comments
 (0)