Skip to content

Commit

Permalink
Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Feb 20, 2024
1 parent e492d12 commit 8fde0f2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand All @@ -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']),
Expand Down Expand Up @@ -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']),
Expand Down Expand Up @@ -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']),
Expand All @@ -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']),
Expand Down Expand Up @@ -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']),
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/tests/Unit/NavItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 8fde0f2

Please sign in to comment.