Skip to content

Commit

Permalink
Merge pull request #839 from hydephp/show-publication-list-pages-in-n…
Browse files Browse the repository at this point in the history
…avigation

Show publication list pages in navigation
  • Loading branch information
caendesilva authored Jan 17, 2023
2 parents 5f5dd96 + 75138cb commit 47cb4dd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/publications/src/Models/PublicationListPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ public function compile(): string
{
return PublicationPageCompiler::call($this);
}

public function showInNavigation(): bool
{
return ! in_array($this->type->getDirectory(), config('hyde.navigation.exclude', []));
}
}
24 changes: 24 additions & 0 deletions packages/publications/tests/Feature/PublicationListPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,30 @@ public function test_listing_page_can_be_compiled()
File::deleteDirectory(Hyde::path('test-publication'));
}

public function test_list_page_can_show_up_in_navigation()
{
$this->createPublicationFiles();

$page = new PublicationListPage($this->getPublicationType());

$this->assertTrue($page->showInNavigation());

File::deleteDirectory(Hyde::path('test-publication'));
}

public function test_list_page_is_not_added_to_navigation_when_publication_identifier_is_set_in_config()
{
config(['hyde.navigation.exclude' => ['test-publication']]);

$this->createPublicationFiles();

$page = new PublicationListPage($this->getPublicationType());

$this->assertFalse($page->showInNavigation());

File::deleteDirectory(Hyde::path('test-publication'));
}

protected function createPublicationFiles(): void
{
mkdir(Hyde::path('test-publication'));
Expand Down

0 comments on commit 47cb4dd

Please sign in to comment.