Skip to content

Commit 57d5130

Browse files
add logic to hid nav bar class if no nav items defined for a top level page section
1 parent 0898d18 commit 57d5130

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/routes/+layout.svelte

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@
123123
}
124124
});
125125
126+
// Check if there are any navigation items to show
127+
const hasNavigationItems = $derived.by(() => {
128+
const groups = navGroupsForCurrentSection;
129+
if (!groups || groups.length === 0) return false;
130+
131+
// Check if any group has items
132+
return groups.some((group) => group.items && group.items.length > 0);
133+
});
134+
126135
// --- MobileNav Related Data Construction ---
127136
// Create structured component items for mobile navigation
128137
const structuredComponentItems =
@@ -206,8 +215,8 @@
206215
class:govuk-width-container={currentPath !== "/"}
207216
>
208217
<div class={currentPath !== "/" ? "app-split-pane" : ""}>
209-
<!-- Side navigation - only shown if not Home -->
210-
{#if currentPath !== "/"}
218+
<!-- Side navigation - only shown if not Home and has navigation items -->
219+
{#if currentPath !== "/" && hasNavigationItems}
211220
<aside class="app-split-pane__nav">
212221
<SideNav
213222
title={getSectionTitle(currentSection)}
@@ -218,7 +227,8 @@
218227
{/if}
219228
<!-- Main content area -->
220229
<div
221-
class:app-split-pane__content={currentPath !== "/"}
230+
class:app-split-pane__content={currentPath !== "/" &&
231+
hasNavigationItems}
222232
class:app-content={currentPath !== "/"}
223233
>
224234
{@render children()}

0 commit comments

Comments
 (0)