diff --git a/packages/publications/src/Models/PublicationListPage.php b/packages/publications/src/Models/PublicationListPage.php index 7dbcb044c8f..8ab1d5efa12 100644 --- a/packages/publications/src/Models/PublicationListPage.php +++ b/packages/publications/src/Models/PublicationListPage.php @@ -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', [])); + } } diff --git a/packages/publications/tests/Feature/PublicationListPageTest.php b/packages/publications/tests/Feature/PublicationListPageTest.php index 6aafa335a01..45477300dd3 100644 --- a/packages/publications/tests/Feature/PublicationListPageTest.php +++ b/packages/publications/tests/Feature/PublicationListPageTest.php @@ -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'));