diff --git a/packages/framework/src/Framework/Features/Navigation/GeneratesDocumentationSidebarMenu.php b/packages/framework/src/Framework/Features/Navigation/GeneratesDocumentationSidebarMenu.php index e71b0a7fb4a..9f2dc75b804 100644 --- a/packages/framework/src/Framework/Features/Navigation/GeneratesDocumentationSidebarMenu.php +++ b/packages/framework/src/Framework/Features/Navigation/GeneratesDocumentationSidebarMenu.php @@ -96,9 +96,12 @@ protected function usesSidebarGroups(): bool protected function makeTitleForGroup(string $group): string { - // Todo search for other labels in the group before slugifying them + // If the label is not formatted, we format it here + if ($group === strtolower($group)) { + return Hyde::makeTitle($group); + } - return Hyde::makeTitle($group); + return $group; } protected function canAddRoute(Route $route): bool diff --git a/packages/framework/tests/Feature/AutomaticNavigationConfigurationsTest.php b/packages/framework/tests/Feature/AutomaticNavigationConfigurationsTest.php index 03fc8d38a94..276bbcf347f 100644 --- a/packages/framework/tests/Feature/AutomaticNavigationConfigurationsTest.php +++ b/packages/framework/tests/Feature/AutomaticNavigationConfigurationsTest.php @@ -203,9 +203,9 @@ public function testMainNavigationMenuWithFrontMatterGroup() // TODO: For new v2 system, this should insert a root item with the group name and the children as the pages $this->assertMenuEquals([ - ['label' => 'Foo', 'group' => 'group-1'], - ['label' => 'Bar', 'group' => 'group-1'], - ['label' => 'Baz', 'group' => 'group-1'], + ['label' => 'Foo', 'group' => 'Group 1'], + ['label' => 'Bar', 'group' => 'Group 1'], + ['label' => 'Baz', 'group' => 'Group 1'], ], [ new MarkdownPage('foo', ['navigation.group' => 'Group 1']), new MarkdownPage('bar', ['navigation.group' => 'Group 1']), @@ -218,9 +218,9 @@ public function testMainNavigationMenuWithFrontMatterCategory() // TODO: For new v2 system, this should insert a root item with the group name and the children as the pages $this->assertMenuEquals([ - ['label' => 'Foo', 'group' => 'group-1'], - ['label' => 'Bar', 'group' => 'group-1'], - ['label' => 'Baz', 'group' => 'group-1'], + ['label' => 'Foo', 'group' => 'Group 1'], + ['label' => 'Bar', 'group' => 'Group 1'], + ['label' => 'Baz', 'group' => 'Group 1'], ], [ new MarkdownPage('foo', ['navigation.category' => 'Group 1']), new MarkdownPage('bar', ['navigation.category' => 'Group 1']), @@ -290,7 +290,7 @@ public function testMainNavigationMenuWithFrontMatterGroupAndCategory() { // Since the main key in the navigation schema is 'group', that takes precedence over its 'category' alias - $this->assertMenuEquals(array_fill(0, 3, ['group' => 'group-1']), [ + $this->assertMenuEquals(array_fill(0, 3, ['group' => 'Group 1']), [ new MarkdownPage('foo', ['navigation.group' => 'Group 1', 'navigation.category' => 'Group 2']), new MarkdownPage('bar', ['navigation.group' => 'Group 1', 'navigation.category' => 'Group 2']), new MarkdownPage('baz', ['navigation.group' => 'Group 1', 'navigation.category' => 'Group 2']), @@ -483,8 +483,8 @@ public function testMainNavigationMenuItemsWithTheSameLabelAreNotFilteredForDupl public function testMainNavigationMenuItemsWithSameLabelButDifferentGroupsAreNotFiltered() { $this->assertMenuEquals([ - ['label' => 'Foo', 'group' => 'group-1'], - ['label' => 'Foo', 'group' => 'group-2'], + ['label' => 'Foo', 'group' => 'Group 1'], + ['label' => 'Foo', 'group' => 'Group 2'], ], [ new MarkdownPage('foo', ['navigation.label' => 'Foo', 'navigation.group' => 'Group 1']), new MarkdownPage('bar', ['navigation.label' => 'Foo', 'navigation.group' => 'Group 2']), @@ -496,9 +496,8 @@ public function testMainNavigationMenuDropdownItemsWithSameLabelButDifferentGrou config(['hyde.navigation.subdirectories' => 'dropdown']); $this->assertMenuEquals([ - // Todo: Should use proper group name - ['label' => 'group-1', 'children' => ['Foo']], - ['label' => 'group-2', 'children' => ['Foo']], + ['label' => 'Group 1', 'children' => ['Foo']], + ['label' => 'Group 2', 'children' => ['Foo']], ], [ new MarkdownPage('one/foo', ['navigation.group' => 'Group 1']), new MarkdownPage('two/foo', ['navigation.group' => 'Group 2']), @@ -980,8 +979,6 @@ public function testSidebarItemGroupingIsNormalized() public function testSidebarLabelsRetainBestFormatting() { - $this->markTestSkipped('Not yet implemented'); - $this->assertSidebarEquals(['GitHub'], [ new DocumentationPage('foo', ['navigation.group' => 'GitHub']), new DocumentationPage('bar', ['navigation.group' => 'github']), diff --git a/packages/framework/tests/Unit/NavItemTest.php b/packages/framework/tests/Unit/NavItemTest.php index ebcd7e675dd..527cb8b5ea0 100644 --- a/packages/framework/tests/Unit/NavItemTest.php +++ b/packages/framework/tests/Unit/NavItemTest.php @@ -345,8 +345,8 @@ public function testGetGroupForRouteWithGroup() public function testGroupKeysAreNormalized() { - $item = new NavItem(new Route(new MarkdownPage()), 'Test', 500, 'Foo Bar'); - $this->assertSame('foo-bar', $item->getGroup()); + $this->assertSame('Foo Bar', (new NavItem(new Route(new MarkdownPage()), 'Test', 500, 'Foo Bar'))->getGroup()); + $this->assertSame('Foo Bar', (new NavItem(new Route(new MarkdownPage()), 'Test', 500, 'foo-bar'))->getGroup()); } public function testIdentifier()