mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-25 06:56:56 +02:00
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
This commit is contained in:
parent
edde297504
commit
a2d3f26722
8 changed files with 466 additions and 139 deletions
24
v2/lib/theme/Sidebar/SidebarLink.js
Normal file
24
v2/lib/theme/Sidebar/SidebarLink.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
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>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue