Skip to content

Commit

Permalink
Get the search page from the kernel as well
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 14, 2023
1 parent e80cbb2 commit 03f7fd8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 03f7fd8

Please sign in to comment.