diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 1883d530bf2..8f5df265e4e 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -18,6 +18,7 @@ This serves two purposes: ### Changed - Realtime Compiler: The `DashboardController` class is now marked as internal, as it is not intended to be used outside of the package https://github.com/hydephp/develop/pull/1394 - Updated the realtime compiler server configuration options in https://github.com/hydephp/develop/pull/1395 (backwards compatible) +- Updated the realtime compiler to generate the documentation search index each time it's requested in https://github.com/hydephp/develop/pull/1405 (fixes https://github.com/hydephp/develop/issues/1404) ### Deprecated - for soon-to-be removed features. @@ -31,6 +32,7 @@ This serves two purposes: - Updated the vendor publish command to support parent Laravel Prompts implementation in https://github.com/hydephp/develop/pull/1388 - Fixed wrong version constant in https://github.com/hydephp/develop/pull/1391 - Fixed improperly formatted exception message in https://github.com/hydephp/develop/pull/1399 +- Fixed missing support for missing and out of date search indexes when previewing site https://github.com/hydephp/develop/issues/1404 in https://github.com/hydephp/develop/pull/1405 ### Security - in case of vulnerabilities. diff --git a/docs/creating-content/documentation-pages.md b/docs/creating-content/documentation-pages.md index 752498e7ce5..c3694d3350f 100644 --- a/docs/creating-content/documentation-pages.md +++ b/docs/creating-content/documentation-pages.md @@ -292,12 +292,9 @@ navigation menu items are hidden. The page will still be accessible as normal bu ] ``` -### Search with realtime compiler - -While the Realtime Compiler (what powers the `php hyde serve` command) serves the search index, however, it does not -compile the index automatically. So if you're missing the search when previewing your site, run either `php hyde build` -or `php hyde build:search` to compile the search index. +### Live search with the realtime compiler +The Realtime Compiler that powers the `php hyde serve` command will automatically generate a fresh search index each time the browser requests it. ## Automatic "Edit Page" button diff --git a/packages/realtime-compiler/src/Routing/Router.php b/packages/realtime-compiler/src/Routing/Router.php index 49aa7169d15..9b3ca859784 100644 --- a/packages/realtime-compiler/src/Routing/Router.php +++ b/packages/realtime-compiler/src/Routing/Router.php @@ -8,10 +8,13 @@ use Hyde\RealtimeCompiler\Actions\AssetFileLocator; use Hyde\RealtimeCompiler\Concerns\SendsErrorResponses; use Hyde\RealtimeCompiler\Models\FileObject; +use Hyde\RealtimeCompiler\Concerns\InteractsWithLaravel; +use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex; class Router { use SendsErrorResponses; + use InteractsWithLaravel; protected Request $request; @@ -71,6 +74,10 @@ protected function shouldProxy(Request $request): bool */ protected function proxyStatic(): Response { + if ($this->request->path === '/docs/search.json') { + $this->generateSearchIndex(); + } + $path = AssetFileLocator::find($this->request->path); if ($path === null) { @@ -86,4 +93,14 @@ protected function proxyStatic(): Response 'Content-Length' => $file->getContentLength(), ]); } + + /** + * Generate the documentation search index. + */ + protected function generateSearchIndex(): void + { + $this->bootApplication(); + + GeneratesDocumentationSearchIndex::handle(); + } }