From 426e73b61252b33c2f4970d84cff4f1c5b20cad9 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Mon, 16 Jan 2023 15:18:29 +0100 Subject: [PATCH 1/3] Update to show publication list pages in navigation --- packages/publications/src/Models/PublicationListPage.php | 5 +++++ .../tests/Feature/PublicationListPageTest.php | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/packages/publications/src/Models/PublicationListPage.php b/packages/publications/src/Models/PublicationListPage.php index 7dbcb044c8f..969eeb6b896 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 true; + } } diff --git a/packages/publications/tests/Feature/PublicationListPageTest.php b/packages/publications/tests/Feature/PublicationListPageTest.php index 6aafa335a01..5041921b186 100644 --- a/packages/publications/tests/Feature/PublicationListPageTest.php +++ b/packages/publications/tests/Feature/PublicationListPageTest.php @@ -41,6 +41,15 @@ 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()); + } + protected function createPublicationFiles(): void { mkdir(Hyde::path('test-publication')); From c98338e0e3d33b9d07d2d043ed92100ed4aeb2a4 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 17 Jan 2023 13:15:11 +0100 Subject: [PATCH 2/3] Clean up after the test --- packages/publications/tests/Feature/PublicationListPageTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/publications/tests/Feature/PublicationListPageTest.php b/packages/publications/tests/Feature/PublicationListPageTest.php index 5041921b186..a6492644581 100644 --- a/packages/publications/tests/Feature/PublicationListPageTest.php +++ b/packages/publications/tests/Feature/PublicationListPageTest.php @@ -48,6 +48,8 @@ public function test_list_page_can_show_up_in_navigation() $page = new PublicationListPage($this->getPublicationType()); $this->assertTrue($page->showInNavigation()); + + File::deleteDirectory(Hyde::path('test-publication')); } protected function createPublicationFiles(): void From 75138cb71911116a5225d3db75d11c39cdc380c7 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 17 Jan 2023 13:15:27 +0100 Subject: [PATCH 3/3] Only show publication list pages in navigation when not excluded --- .../publications/src/Models/PublicationListPage.php | 2 +- .../tests/Feature/PublicationListPageTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/publications/src/Models/PublicationListPage.php b/packages/publications/src/Models/PublicationListPage.php index 969eeb6b896..8ab1d5efa12 100644 --- a/packages/publications/src/Models/PublicationListPage.php +++ b/packages/publications/src/Models/PublicationListPage.php @@ -31,6 +31,6 @@ public function compile(): string public function showInNavigation(): bool { - return true; + 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 a6492644581..45477300dd3 100644 --- a/packages/publications/tests/Feature/PublicationListPageTest.php +++ b/packages/publications/tests/Feature/PublicationListPageTest.php @@ -52,6 +52,19 @@ public function test_list_page_can_show_up_in_navigation() 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'));