Skip to content

Commit 0f9645d

Browse files
authored
Add icon for external links (#1098)
* feat: add external link styling * feat: exclude links to k6.io
1 parent f427433 commit 0f9645d

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/components/shared/link/link.module.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,11 @@
4949
}
5050
}
5151
}
52+
.external {
53+
display: inline-flex;
54+
align-items: center;
55+
56+
svg {
57+
margin-left: 6px;
58+
}
59+
}

src/components/shared/link/link.view.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React from 'react';
22
import { LATEST_VERSION } from 'utils/versioning';
33

4+
import styles from './link.module.scss';
5+
import ExternalIcon from './svg/exnternal-link-icon.inline.svg';
6+
47
export const Link =
58
(version) =>
69
({ href, children, ...otherProps }) => {
@@ -9,7 +12,18 @@ export const Link =
912
? href.replace('/javascript-api/', `/${version}/javascript-api/`)
1013
: href;
1114

12-
return (
15+
return href.startsWith('http') && !href.includes('k6.io/') ? (
16+
<a
17+
className={styles.external}
18+
href={newHref}
19+
target="_blank"
20+
rel="noreferrer"
21+
{...otherProps}
22+
>
23+
{children}
24+
<ExternalIcon />
25+
</a>
26+
) : (
1327
<a href={newHref} {...otherProps}>
1428
{children}
1529
</a>
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)