Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
awxiaoxian2020 committed Oct 11, 2023
1 parent f3962e5 commit 8a139e7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/components/Sidebar/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function Sidebar({ className = '', pages, currentPage }) {
>
{versions.map((version) => (
<option key={version} value={version}>
Webpack {version}
webpack {version}
</option>
))}
</select>
Expand Down
8 changes: 1 addition & 7 deletions src/components/Sidebar/Sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@
padding: 1.5em;
position: sticky;
top: -1px;
overflow: scroll;
overflow-y: auto;
max-height: 100vh;
// To hide scrollbar in Firefox
scrollbar-width: none;
// To hide scrollbar in Chrome
&::-webkit-scrollbar {
width: 0 !important;
}
}

.sidebar__group {
Expand Down
38 changes: 12 additions & 26 deletions src/components/SidebarItem/SidebarItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,22 @@ export default class SidebarItem extends Component {
renderAnchors(anchors) {
return (
<ul className={`${block}__anchors`}>
{anchors.map((anchor) => {
anchor = this._handleAnchor(anchor);
return (
<li
key={this._generateAnchorURL(anchor)}
className={`${block}__anchor`}
title={anchor.title}
>
<NavLink to={this._generateAnchorURL(anchor)}>
{anchor.title}
</NavLink>
{anchor.children && this.renderAnchors(anchor.children)}
</li>
);
})}
{anchors.map((anchor) => (
<li
key={this._generateAnchorURL(anchor)}
className={`${block}__anchor`}
title={anchor.title}
>
<NavLink to={this._generateAnchorURL(anchor)}>
{anchor.title2}
</NavLink>
{anchor.children && this.renderAnchors(anchor.children)}
</li>
))}
</ul>
);
}

_handleAnchor(anchor) {
let id = anchor.id;
let title = anchor.title2;
const match = /^.+(\s*\$#([a-z0-9\-_]+?)\$\s*)$/.exec(title);
id = match ? match[2] : id;
title = match ? title.replace(match[1], '').trim() : title;
anchor.id = id;
anchor.title = title;
return anchor;
}

render() {
let { title, anchors = [] } = this.props;
let openMod = this.state.open ? `${block}--open` : '';
Expand Down

0 comments on commit 8a139e7

Please sign in to comment.