diff options
author | 安竹洋平 <61961825+yasutakeyohei@users.noreply.github.com> | 2024-05-23 00:25:57 +0900 |
---|---|---|
committer | 安竹洋平 <61961825+yasutakeyohei@users.noreply.github.com> | 2024-05-23 00:25:57 +0900 |
commit | ad0c3063ba78c6eb66399d12d87de53c34ed01ba (patch) | |
tree | 6d6fb9f58aaa8d01efe8572803aa7dc48434fed2 | |
parent | 30121e3c4fbd33d5b85b9ddd505e2d9251b44839 (diff) |
hrefがない場合はリンクしないよう修正
-rw-r--r-- | src/components/ExternalLink.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/components/ExternalLink.js b/src/components/ExternalLink.js index 82c87300..71e09dd9 100644 --- a/src/components/ExternalLink.js +++ b/src/components/ExternalLink.js @@ -3,9 +3,14 @@ import React from 'react'; import ExternalLinkIcon from '@theme/Icon/ExternalLink'; export default function ExternalLink({children, href}) { + if(href) { + return ( + <a href={href} rel={"noopener noreferrer"} target={"_blank"}> + {children} <ExternalLinkIcon /> + </a> + ); + } return ( - <a href={href} rel={"noopener noreferrer"} target={"_blank"}> - {children} <ExternalLinkIcon /> - </a> + <>{children}</> ); }
\ No newline at end of file |