Skip to content

Commit

Permalink
Add index page to the sidebar when it's the only page
Browse files Browse the repository at this point in the history
Automatically include the index page in the documentation sidebar when it is the only page present. This ensures the sidebar is not empty for a single-page documentation site, providing a more user-friendly experience.
  • Loading branch information
caendesilva committed Nov 26, 2023
1 parent 34eaffb commit d3598ac
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ protected function generate(): void
$this->items->put($route->getRouteKey(), NavItem::fromRoute($route));
}
});

// If there are no pages other than the index page, we add it to the sidebar so that it's not empty
if($this->items->count() === 0 && DocumentationPage::home() !== null) {
$this->items->push(NavItem::fromRoute(DocumentationPage::home()));
}
}

public function hasGroups(): bool
Expand Down

0 comments on commit d3598ac

Please sign in to comment.