Skip to content

Commit

Permalink
Merge pull request #584 from hydephp/framework-v1.3.4
Browse files Browse the repository at this point in the history
HydePHP v1.3.4 - 2023-11-26
  • Loading branch information
caendesilva authored Nov 26, 2023
2 parents c4b8281 + 799f8e4 commit f1fd610
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Foundation/HydeKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class HydeKernel implements SerializableContract
use Serializable;
use Macroable;

final public const VERSION = '1.3.3';
final public const VERSION = '1.3.4';

protected static self $instance;

Expand Down
5 changes: 5 additions & 0 deletions src/Framework/Features/Navigation/DocumentationSidebar.php
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(), group: 'other'));
}
}

public function hasGroups(): bool
Expand Down
25 changes: 25 additions & 0 deletions tests/Feature/Services/DocumentationSidebarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,31 @@ public function test_is_group_active_for_index_page_with_no_groups()
$this->assertFalse(DocumentationSidebar::create()->isGroupActive('foo'));
}

public function test_index_page_added_to_sidebar_when_it_is_the_only_page()
{
Filesystem::touch('_docs/index.md');
$sidebar = DocumentationSidebar::create();

$this->assertCount(1, $sidebar->items);
$this->assertEquals(
collect([NavItem::fromRoute(Routes::get('docs/index'))]),
$sidebar->items
);
}

public function test_index_page_not_added_to_sidebar_when_other_pages_exist()
{
$this->createTestFiles(1);
Filesystem::touch('_docs/index.md');
$sidebar = DocumentationSidebar::create();

$this->assertCount(1, $sidebar->items);
$this->assertEquals(
collect([NavItem::fromRoute(Routes::get('docs/test-0'))]),
$sidebar->items
);
}

protected function createTestFiles(int $count = 5): void
{
for ($i = 0; $i < $count; $i++) {
Expand Down

0 comments on commit f1fd610

Please sign in to comment.