From 03f7fd897735c097bffb7b3cd27da505059c8680 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 14 Dec 2023 17:15:54 +0100 Subject: [PATCH] Get the search page from the kernel as well --- .../framework/src/Console/Commands/BuildSearchCommand.php | 2 +- .../tests/Feature/Commands/BuildSearchCommandTest.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Console/Commands/BuildSearchCommand.php b/packages/framework/src/Console/Commands/BuildSearchCommand.php index a0248172a17..563778da0b1 100644 --- a/packages/framework/src/Console/Commands/BuildSearchCommand.php +++ b/packages/framework/src/Console/Commands/BuildSearchCommand.php @@ -26,7 +26,7 @@ public function handle(): int StaticPageBuilder::handle(Pages::get('search.json') ?? GeneratesDocumentationSearchIndex::makePage()); if (DocumentationSearchPage::enabled()) { - DocumentationSearchPage::generate(); + StaticPageBuilder::handle(Pages::get('docs/search') ?? new DocumentationSearchPage()); } return Command::SUCCESS; diff --git a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php index bd25e01bd78..72a5f591930 100644 --- a/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php +++ b/packages/framework/tests/Feature/Commands/BuildSearchCommandTest.php @@ -106,15 +106,21 @@ public function test_search_files_can_be_generated_for_custom_site_and_nested_do Filesystem::deleteDirectory('foo'); } - public function test_command_uses_page_from_kernel_when_present() + public function test_command_uses_search_pages_from_kernel_when_present() { Hyde::pages()->addPage(tap(GeneratesDocumentationSearchIndex::makePage(), function (InMemoryPage $page): void { $page->macro('compile', fn () => '{"foo":"bar"}'); })); + Hyde::pages()->addPage(tap(new InMemoryPage('docs/search'), function (InMemoryPage $page): void { + $page->macro('compile', fn () => 'Foo'); + })); + $this->artisan('build:search')->assertExitCode(0); $this->assertFileExists(Hyde::path('_site/docs/search.json')); + $this->assertFileExists(Hyde::path('_site/docs/search.html')); $this->assertSame('{"foo":"bar"}', Filesystem::getContents('_site/docs/search.json')); + $this->assertSame('Foo', Filesystem::getContents('_site/docs/search.html')); Filesystem::unlink('_site/docs/search.json'); Filesystem::unlink('_site/docs/search.html');