Skip to content

Commit

Permalink
Breaking: Rename subdirectories option to subdirectory_display
Browse files Browse the repository at this point in the history
Breaking: Renames the `hyde.navigation.subdirectories` option to `hyde.navigation.subdirectory_display` to make its usage much clearer.
  • Loading branch information
caendesilva committed Jul 10, 2024
1 parent 709bc35 commit c06a475
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@

// How should pages in subdirectories be displayed in the menu?
// You can choose between 'dropdown', 'flat', and 'hidden'.
'subdirectories' => 'hidden',
'subdirectory_display' => 'hidden',
],

/*
Expand Down
4 changes: 2 additions & 2 deletions docs/digging-deeper/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Within the Hyde config you can configure how subdirectories should be displayed
```php
// filepath config/hyde.php
'navigation' => [
'subdirectories' => 'dropdown'
'subdirectory_display' => 'dropdown'
]
```

Expand All @@ -279,7 +279,7 @@ For pages that can be in the main site menu, this feature needs to be enabled in
// filepath config/hyde.php
'navigation' => [
'subdirectories' => 'dropdown',
'subdirectory_display' => 'dropdown',
],
```

Expand Down
2 changes: 1 addition & 1 deletion packages/framework/config/hyde.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@

// How should pages in subdirectories be displayed in the menu?
// You can choose between 'dropdown', 'flat', and 'hidden'.
'subdirectories' => 'hidden',
'subdirectory_display' => 'hidden',
],

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private function getSubdirectoryName(): string

protected function getSubdirectoryConfiguration(): string
{
return Config::getString('hyde.navigation.subdirectories', 'hidden');
return Config::getString('hyde.navigation.subdirectory_display', 'hidden');
}

/** @param class-string<\Hyde\Pages\Concerns\HydePage> $class */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function usesGroups(): bool

return $this->routes->first(fn (Route $route): bool => filled($route->getPage()->navigationMenuGroup())) !== null;
} else {
return Config::getString('hyde.navigation.subdirectories', 'hidden') === 'dropdown';
return Config::getString('hyde.navigation.subdirectory_display', 'hidden') === 'dropdown';
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public function testMainNavigationDropdownLabelsCanBeSetInConfig()

public function testMainNavigationAutomaticSubdirectoryDropdownLabelsCanBeSetInConfig()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);
config(['hyde.navigation.labels' => ['hello' => 'World']]);

$this->assertMenuEquals(['World'], [
Expand Down Expand Up @@ -444,7 +444,7 @@ public function testPagesInSubdirectoriesAreNotAddedToNavigation()

public function testPagesInSubdirectoriesAreAddedToNavigationWhenNavigationSubdirectoriesIsSetToFlat()
{
config(['hyde.navigation.subdirectories' => 'flat']);
config(['hyde.navigation.subdirectory_display' => 'flat']);

$this->assertMenuEquals(['Foo', 'Bar', 'Baz'], [
new MarkdownPage('about/foo'),
Expand All @@ -455,7 +455,7 @@ public function testPagesInSubdirectoriesAreAddedToNavigationWhenNavigationSubdi

public function testPagesInSubdirectoriesAreAddedAsDropdownsWhenNavigationSubdirectoriesIsSetToDropdown()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);

$this->assertMenuEquals([
['label' => 'About', 'children' => ['Foo', 'Bar', 'Baz']],
Expand Down Expand Up @@ -502,7 +502,7 @@ public function testMainNavigationMenuItemsWithSameLabelButDifferentGroupsAreNot

public function testMainNavigationMenuDropdownItemsWithSameLabelButDifferentGroupsAreNotFiltered()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);

$this->assertMenuEquals([
['label' => 'One', 'children' => ['Foo']],
Expand All @@ -515,7 +515,7 @@ public function testMainNavigationMenuDropdownItemsWithSameLabelButDifferentGrou

public function testMainNavigationMenuAutomaticDropdownItemsWithSameLabelButDifferentGroupsAreNotFiltered()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);

$this->assertMenuEquals([
['label' => 'One', 'children' => ['Foo']],
Expand All @@ -532,7 +532,7 @@ public function testConflictingSubdirectoryAndFrontMatterDropdownConfigurationGi
// we run into a conflicting state where we don't know what the user intended. We solve this by giving
// precedence to the subdirectory configuration. This is opinionated, but allows for good grouping.

config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);

$this->assertMenuEquals([
['label' => 'Foo', 'children' => ['Child']],
Expand All @@ -543,7 +543,7 @@ public function testConflictingSubdirectoryAndFrontMatterDropdownConfigurationGi

public function testCanMixSubdirectoryDropdownsWithFrontMatterDropdowns()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);

$this->assertMenuEquals([
['label' => 'Foo', 'children' => ['Bar', 'Baz']],
Expand All @@ -555,7 +555,7 @@ public function testCanMixSubdirectoryDropdownsWithFrontMatterDropdowns()

public function testMainMenuAutomaticDropdownLabelsCanBeSetInConfig()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);
config(['hyde.navigation.labels' => ['foo' => 'Bar']]);

$this->assertMenuEquals([
Expand Down Expand Up @@ -1110,7 +1110,7 @@ public function testSidebarCanMixSubdirectoryGroupsWithFrontMatterGroups()

public function testMainNavigationDropdownPriorityCanBeSetInConfig()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);
config(['hyde.navigation.order' => ['foo' => 500]]);

$this->assertMenuEquals(
Expand All @@ -1121,7 +1121,7 @@ public function testMainNavigationDropdownPriorityCanBeSetInConfig()

public function testMainNavigationDropdownPriorityCanBeSetInConfigUsingDifferingCases()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);
config(['hyde.navigation.order' => ['hello-world' => 500]]);

$expected = [['label' => 'Hello World', 'priority' => 500]];
Expand Down Expand Up @@ -1176,7 +1176,7 @@ public function testMainMenuNavigationItemCasingUsingFrontMatter()

public function testMainMenuNavigationGroupCasing()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);

// When using subdirectory groupings, we try to format them the same way as the page titles

Expand Down
6 changes: 3 additions & 3 deletions packages/framework/tests/Feature/HydePageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ public function testNavigationDataFactoryHidesPageFromNavigationWhenInASubdirect

public function testNavigationDataFactoryHidesPageFromNavigationWhenInAAndConfigIsSetToHidden()
{
config(['hyde.navigation.subdirectories' => 'hidden']);
config(['hyde.navigation.subdirectory_display' => 'hidden']);

$page = MarkdownPage::make('foo/bar');

Expand All @@ -1186,7 +1186,7 @@ public function testNavigationDataFactoryHidesPageFromNavigationWhenInAAndConfig

public function testNavigationDataFactoryDoesNotHidePageFromNavigationWhenInASubdirectoryAndAllowedInConfiguration()
{
config(['hyde.navigation.subdirectories' => 'flat']);
config(['hyde.navigation.subdirectory_display' => 'flat']);

$page = MarkdownPage::make('foo/bar');

Expand All @@ -1196,7 +1196,7 @@ public function testNavigationDataFactoryDoesNotHidePageFromNavigationWhenInASub

public function testNavigationDataFactoryAllowsShowInNavigationAndSetsGroupWhenDropdownIsSelectedInConfig()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);

$page = MarkdownPage::make('foo/bar');

Expand Down
6 changes: 3 additions & 3 deletions packages/framework/tests/Feature/NavigationMenuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function testPagesInSubdirectoriesAreNotAddedToTheNavigationMenu()

public function testPagesInSubdirectoriesCanBeAddedToTheNavigationMenuWithConfigFlatSetting()
{
config(['hyde.navigation.subdirectories' => 'flat']);
config(['hyde.navigation.subdirectory_display' => 'flat']);
$this->directory('_pages/foo');
$this->file('_pages/foo/bar.md');

Expand All @@ -256,7 +256,7 @@ public function testPagesInSubdirectoriesCanBeAddedToTheNavigationMenuWithConfig

public function testPagesInSubdirectoriesAreNotAddedToTheNavigationMenuWithConfigDropdownSetting()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);
$this->directory('_pages/foo');
$this->file('_pages/foo/bar.md');

Expand All @@ -275,7 +275,7 @@ public function testPagesInSubdirectoriesAreNotAddedToTheNavigationMenuWithConfi

public function testPagesInDropdownsDoNotGetAddedToTheMainNavigation()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);

Routes::push((new MarkdownPage('foo'))->getRoute());
Routes::push((new MarkdownPage('bar/baz'))->getRoute());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp(): void

$this->helper = new FilenamePrefixNavigationPriorityTestingHelper($this);

Config::set('hyde.navigation.subdirectories', 'dropdown');
Config::set('hyde.navigation.subdirectory_display', 'dropdown');

// Todo: Replace kernel with mock class
$this->withoutDefaultPages();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function testMakeGroupUsesFrontMatterGroupIfSet()

public function testMakeGroupUsesFrontMatterGroupIfSetRegardlessOfSubdirectoryConfiguration()
{
self::mockConfig(['hyde.navigation.subdirectories' => 'hidden']);
self::mockConfig(['hyde.navigation.subdirectory_display' => 'hidden']);

$frontMatter = new FrontMatter(['navigation.group' => 'Test Group']);
$coreDataObject = new CoreDataObject($frontMatter, new Markdown(), MarkdownPage::class, 'test.md', '', '', '');
Expand All @@ -259,7 +259,7 @@ public function testMakeGroupUsesFrontMatterGroupIfSetRegardlessOfSubdirectoryCo

public function testMakeGroupDefaultsToNullIfFrontMatterGroupNotSetAndSubdirectoriesNotUsed()
{
self::mockConfig(['hyde.navigation.subdirectories' => 'hidden']);
self::mockConfig(['hyde.navigation.subdirectory_display' => 'hidden']);

$coreDataObject = new CoreDataObject(new FrontMatter(), new Markdown(), MarkdownPage::class, 'test.md', '', '', '');
$factory = new NavigationConfigTestClass($coreDataObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function setUp(): void
parent::setUp();

config(['hyde.enable_cache_busting' => false]);
config(['hyde.navigation.subdirectories' => 'flat']);
config(['hyde.navigation.subdirectory_display' => 'flat']);

$this->needsDirectory('_pages/nested');
$this->file('_pages/root.md');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ protected function sidebar(array $withPages = []): RenderedDocumentationSidebarM

protected function useSubdirectoryConfig(string $option): static
{
config(['hyde.navigation.subdirectories' => $option]);
config(['hyde.navigation.subdirectory_display' => $option]);

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function testNavigationMenuWithRootPages()

public function testNavigationMenuWithDropdownPages()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);

$page = new MarkdownPage('page');
$bar = new MarkdownPage('foo/bar');
Expand All @@ -104,7 +104,7 @@ public function testNavigationMenuWithDropdownPages()

public function testNavigationMenuWithDropdownPagesWithRootGroupPage()
{
config(['hyde.navigation.subdirectories' => 'dropdown']);
config(['hyde.navigation.subdirectory_display' => 'dropdown']);

$foo = new MarkdownPage('foo');
$bar = new MarkdownPage('foo/bar');
Expand Down

2 comments on commit c06a475

@caendesilva
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to stick closely to the original meaning while improving clarity, "subdirectory_handling" or "subdirectory_navigation" might be good choices. If we want to be more specific about it being related to the menu structure, "subdirectory_menu_behavior" could work well.

@caendesilva
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But since we have the word "displayed" in the inline documentation, I think that's fine.

Please sign in to comment.