Skip to content

Commit c34eba0

Browse files
committed
fix(mobile): clean up and simplify link/section data passed to SidebarMobile
1 parent f20b530 commit c34eba0

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

components/site/site.jsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,19 @@ import '../logo/logo-style';
2020
import '../dropdown/dropdown-style.scss';
2121

2222
export default props => {
23-
// Retrieve section data
24-
let sections = props.children.props.section.all()
25-
.map(({ title, url, pages }) => ({
26-
title,
27-
url,
28-
pages: pages.map(({ title, url }) => ({
29-
title: title || url, // XXX: Title shouldn't be coming in as undefined
30-
url
23+
// Retrieve and clean up section data
24+
let sections = (
25+
props.children.props.section.all()
26+
.filter(section => section.pages.length !== 0)
27+
.map(({ title, url, pages }) => ({
28+
title,
29+
url,
30+
pages: pages.map(({ title, url }) => ({
31+
title: title || url, // XXX: Title shouldn't be coming in as undefined
32+
url
33+
}))
3134
}))
32-
}));
33-
34-
// Rename the root section ("webpack" => "Other") and push it to the end
35-
let rootIndex = sections.findIndex(section => section.title === 'webpack');
36-
let rootSection = sections.splice(rootIndex, 1)[0];
37-
rootSection.title = 'Other';
38-
sections.push(rootSection);
35+
);
3936

4037
return (
4138
<div id="site" className="site">

0 commit comments

Comments
 (0)