Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit 03ae7c1

Browse files
committed
Fix sidebarnav for sites with no root pages in the sidebar config
1 parent 9caae31 commit 03ae7c1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/gatsby-theme-apollo-core/src/components/sidebar-nav.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export default function SidebarNav(props) {
164164

165165
const [allExpanded, setAllExpanded] = useState(false);
166166
const categories = props.contents.filter(content => content.title);
167-
const [{pages}] = props.contents.filter(content => !content.title);
167+
const [root] = props.contents.filter(content => !content.title);
168168

169169
function toggleAll() {
170170
const checkboxes = Array.from(
@@ -196,11 +196,13 @@ export default function SidebarNav(props) {
196196

197197
return (
198198
<>
199-
<NavItems
200-
pages={pages}
201-
pathname={props.pathname}
202-
onLinkClick={props.onLinkClick}
203-
/>
199+
{root && (
200+
<NavItems
201+
pages={root.pages}
202+
pathname={props.pathname}
203+
onLinkClick={props.onLinkClick}
204+
/>
205+
)}
204206
{!props.alwaysExpanded && categories.length > 1 && (
205207
<ExpandAll onClick={toggleAll}>
206208
{React.createElement(allExpanded ? IconCollapseList : IconExpandList)}

0 commit comments

Comments
 (0)