diff --git a/packages/framework/src/Foundation/HydeCoreExtension.php b/packages/framework/src/Foundation/HydeCoreExtension.php index 6c48936a370..669e68056eb 100644 --- a/packages/framework/src/Foundation/HydeCoreExtension.php +++ b/packages/framework/src/Foundation/HydeCoreExtension.php @@ -8,10 +8,13 @@ use Hyde\Pages\BladePage; use Hyde\Pages\MarkdownPage; use Hyde\Pages\MarkdownPost; +use Hyde\Pages\InMemoryPage; use Hyde\Pages\DocumentationPage; +use Hyde\Foundation\Kernel\PageCollection; use Hyde\Foundation\Concerns\HydeExtension; use Hyde\Facades\Features; +use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; use function array_filter; use function array_keys; @@ -28,4 +31,18 @@ public static function getPageClasses(): array DocumentationPage::class => Features::hasDocumentationPages(), ], fn (bool $value): bool => $value)); } + + public function discoverPages(PageCollection $collection): void + { + if (Features::hasDocumentationSearch()) { + $collection->addPage(tap(new InMemoryPage('search.json'), function (InMemoryPage $page): void { + $page->macro('compile', function (): string { + return GeneratesDocumentationSearchIndex::generate(); + }); + $page->macro('getOutputPath', function (): string { + return DocumentationPage::outputDirectory().'/search.json'; + }); + })); + } + } }