Skip to content

Commit e1535a4

Browse files
authored
Merge pull request #1405 from hydephp/support-realtime-documentation-searches-in-realtime-compiler
Update realtime compiler to generate search indexes on demand
2 parents a42101d + 4ba0cfa commit e1535a4

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This serves two purposes:
1818
### Changed
1919
- 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
2020
- Updated the realtime compiler server configuration options in https://github.com/hydephp/develop/pull/1395 (backwards compatible)
21+
- 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)
2122

2223
### Deprecated
2324
- for soon-to-be removed features.
@@ -31,6 +32,7 @@ This serves two purposes:
3132
- Updated the vendor publish command to support parent Laravel Prompts implementation in https://github.com/hydephp/develop/pull/1388
3233
- Fixed wrong version constant in https://github.com/hydephp/develop/pull/1391
3334
- Fixed improperly formatted exception message in https://github.com/hydephp/develop/pull/1399
35+
- 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
3436

3537
### Security
3638
- in case of vulnerabilities.

docs/creating-content/documentation-pages.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,9 @@ navigation menu items are hidden. The page will still be accessible as normal bu
292292
]
293293
```
294294

295-
### Search with realtime compiler
296-
297-
While the Realtime Compiler (what powers the `php hyde serve` command) serves the search index, however, it does not
298-
compile the index automatically. So if you're missing the search when previewing your site, run either `php hyde build`
299-
or `php hyde build:search` to compile the search index.
295+
### Live search with the realtime compiler
300296

297+
The Realtime Compiler that powers the `php hyde serve` command will automatically generate a fresh search index each time the browser requests it.
301298

302299
## Automatic "Edit Page" button
303300

packages/realtime-compiler/src/Routing/Router.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
use Hyde\RealtimeCompiler\Actions\AssetFileLocator;
99
use Hyde\RealtimeCompiler\Concerns\SendsErrorResponses;
1010
use Hyde\RealtimeCompiler\Models\FileObject;
11+
use Hyde\RealtimeCompiler\Concerns\InteractsWithLaravel;
12+
use Hyde\Framework\Actions\GeneratesDocumentationSearchIndex;
1113

1214
class Router
1315
{
1416
use SendsErrorResponses;
17+
use InteractsWithLaravel;
1518

1619
protected Request $request;
1720

@@ -71,6 +74,10 @@ protected function shouldProxy(Request $request): bool
7174
*/
7275
protected function proxyStatic(): Response
7376
{
77+
if ($this->request->path === '/docs/search.json') {
78+
$this->generateSearchIndex();
79+
}
80+
7481
$path = AssetFileLocator::find($this->request->path);
7582

7683
if ($path === null) {
@@ -86,4 +93,14 @@ protected function proxyStatic(): Response
8693
'Content-Length' => $file->getContentLength(),
8794
]);
8895
}
96+
97+
/**
98+
* Generate the documentation search index.
99+
*/
100+
protected function generateSearchIndex(): void
101+
{
102+
$this->bootApplication();
103+
104+
GeneratesDocumentationSearchIndex::handle();
105+
}
89106
}

0 commit comments

Comments
 (0)