Skip to content

Commit

Permalink
Add improved conditional to fix override priority
Browse files Browse the repository at this point in the history
Since routes aren't discovered yet, we need to check the pages directly
  • Loading branch information
caendesilva committed Dec 15, 2023
1 parent 0838ab4 commit 1773773
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Hyde\Hyde;
use Hyde\Pages\InMemoryPage;
use Hyde\Pages\DocumentationPage;
use Hyde\Pages\Concerns\HydePage;
use Hyde\Framework\Actions\StaticPageBuilder;
use Hyde\Facades\Config;

Expand Down Expand Up @@ -43,7 +44,13 @@ public function __construct()

public static function enabled(): bool
{
return Config::getBool('docs.create_search_page', true) && ! Hyde::routes()->has(self::routeKey());
return Config::getBool('docs.create_search_page', true) && ! static::anotherSearchPageExists();
}

protected static function anotherSearchPageExists(): bool
{
// Since routes aren't discovered yet, we need to check the pages directly
return Hyde::pages()->first(fn(HydePage $file): bool => $file->getRouteKey() === static::routeKey()) !== null;
}

protected static function routeKey(): string
Expand Down

0 comments on commit 1773773

Please sign in to comment.