mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-04 04:37:28 +02:00
* feat(sidebar): support external links and linking to docs from other sidebars * Update styles.css
24 lines
684 B
JavaScript
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>
|
|
);
|
|
}
|