Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update realtime compiler to generate search indexes on demand #1405

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
7 changes: 2 additions & 5 deletions docs/creating-content/documentation-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions packages/realtime-compiler/src/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -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();
}
}
Loading