From c34eba0273997f718c5b11e667d0aa9125a4db02 Mon Sep 17 00:00:00 2001 From: Greg Venech Date: Sat, 29 Apr 2017 13:05:39 -0400 Subject: [PATCH] fix(mobile): clean up and simplify link/section data passed to `SidebarMobile` --- components/site/site.jsx | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/components/site/site.jsx b/components/site/site.jsx index c5bd357b87ac..8fc05bc64e4b 100644 --- a/components/site/site.jsx +++ b/components/site/site.jsx @@ -20,22 +20,19 @@ import '../logo/logo-style'; import '../dropdown/dropdown-style.scss'; export default props => { - // Retrieve section data - let sections = props.children.props.section.all() - .map(({ title, url, pages }) => ({ - title, - url, - pages: pages.map(({ title, url }) => ({ - title: title || url, // XXX: Title shouldn't be coming in as undefined - url + // Retrieve and clean up section data + let sections = ( + props.children.props.section.all() + .filter(section => section.pages.length !== 0) + .map(({ title, url, pages }) => ({ + title, + url, + pages: pages.map(({ title, url }) => ({ + title: title || url, // XXX: Title shouldn't be coming in as undefined + url + })) })) - })); - - // Rename the root section ("webpack" => "Other") and push it to the end - let rootIndex = sections.findIndex(section => section.title === 'webpack'); - let rootSection = sections.splice(rootIndex, 1)[0]; - rootSection.title = 'Other'; - sections.push(rootSection); + ); return (