From ffd197da642699b005b45d8b3b5a8425ed13208f Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 27 Oct 2023 16:01:15 +0000 Subject: [PATCH] Merge pull request #1396 from hydephp/navigation-data-factory-cleanup Break down complex helper method https://github.com/hydephp/develop/commit/528cd86a2d2cddee4af0a044511ef22f097a4afa --- .../Factories/NavigationDataFactory.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Framework/Factories/NavigationDataFactory.php b/src/Framework/Factories/NavigationDataFactory.php index 0a4a90a4..3c8267f8 100644 --- a/src/Framework/Factories/NavigationDataFactory.php +++ b/src/Framework/Factories/NavigationDataFactory.php @@ -89,9 +89,8 @@ protected function makeHidden(): bool { return $this->isInstanceOf(MarkdownPost::class) || $this->searchForHiddenInFrontMatter() - || in_array($this->routeKey, Config::getArray('hyde.navigation.exclude', ['404'])) - || (! $this->isInstanceOf(DocumentationPage::class) && $this->pageIsInSubdirectory() && ($this->getSubdirectoryConfiguration() === 'hidden')) - && (basename($this->identifier) !== 'index'); + || $this->isPageHiddenInNavigationConfiguration() + || $this->isNonDocumentationPageInHiddenSubdirectory(); } protected function makePriority(): int @@ -119,6 +118,19 @@ private function searchForHiddenInFrontMatter(): ?bool ?? $this->invert($this->getMatter('navigation.visible')); } + private function isPageHiddenInNavigationConfiguration(): ?bool + { + return in_array($this->routeKey, Config::getArray('hyde.navigation.exclude', ['404'])); + } + + private function isNonDocumentationPageInHiddenSubdirectory(): bool + { + return ! $this->isInstanceOf(DocumentationPage::class) + && $this->pageIsInSubdirectory() + && $this->getSubdirectoryConfiguration() === 'hidden' + && basename($this->identifier) !== 'index'; + } + private function searchForPriorityInFrontMatter(): ?int { return $this->getMatter('navigation.priority')