docusaurus/v2/lib/theme/Sidebar/SidebarLink.js
Sviatoslav a2d3f26722 feat(v2): support external links and linking to docs from other sidebars (#1052)
* feat(sidebar): support external links and linking to docs from other sidebars

* Update styles.css
2018-10-25 00:01:39 -04:00

24 lines
684 B
JavaScript

import React from 'react';
import {NavLink} from 'react-router-dom';
import classnames from 'classnames';
import styles from './styles.css';
export default function SidebarLink({href, label}) {
const isExternal = /^(https?:|\/\/)/.test(href);
const Link = isExternal
? // eslint-disable-next-line jsx-a11y/anchor-has-content
({to, activeClassName, ...linkProps}) => <a {...linkProps} href={to} />
: NavLink;
return (
<li className={styles.sidebarListItem}>
<Link
activeClassName={styles.sidebarLinkActive}
className={classnames(styles.sidebarLink, styles.sidebarItem)}
to={href}>
{label}
</Link>
</li>
);
}