Skip to content

Commit

Permalink
Update prop and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dzole0311 committed Oct 16, 2024
1 parent 218f651 commit ed27b16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/scripts/components/common/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ function CardComponent(props: CardComponentPropsType) {
as: linkProperties.LinkElement,
[linkProperties.pathAttributeKeyName]: linkProperties.linkTo,
onLinkClick: linkProperties.onLinkClick,
isLinkExternal: isExternalLink
}}
as={CardItem}
cardType={cardType}
Expand Down
9 changes: 5 additions & 4 deletions app/scripts/components/common/smart-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface SmartLinkProps {
}

/**
* Switches between a `a` and a `Link` depending on the url.
* Switches between a `a` and a `Link` depending on the optional `isLinkExternal` prop or the url.
*/
export default function SmartLink(props: SmartLinkProps) {
const { to, isLinkExternal, onLinkClick, children, ...rest } = props;
Expand All @@ -28,14 +28,15 @@ export default function SmartLink(props: SmartLinkProps) {

interface CustomLinkProps {
href: string;
isLinkExternal?: boolean;
}

/**
* For links defined as markdown, this component will open the external link in a new tab.
* For links defined as markdown, this component will open the external link in a new tab depending on the optional `isLinkExternal` prop or the url.
*/
export function CustomLink(props: CustomLinkProps) {
const { href, ...rest } = props;
const isExternalLink = /^https?:\/\//.test(href);
const { href, isLinkExternal, ...rest } = props;
const isExternalLink = isLinkExternal ?? /^https?:\/\//.test(href);
const linkProps = getLinkProps(href);
return isExternalLink ? (
<a {...linkProps} {...rest} />
Expand Down

0 comments on commit ed27b16

Please sign in to comment.