Skip to content

Commit

Permalink
Update page router to inject live edit scripts when enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 13, 2023
1 parent 3e4e39c commit 9166d4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/realtime-compiler/src/Routing/PageRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Desilva\Microserve\Request;
use Desilva\Microserve\Response;
use Hyde\Foundation\Facades\Routes;
use Hyde\Pages\Concerns\BaseMarkdownPage;
use Hyde\Framework\Actions\StaticPageBuilder;
use Hyde\RealtimeCompiler\Http\LiveEditController;
use Hyde\Framework\Features\Documentation\DocumentationSearchPage;
Expand Down Expand Up @@ -75,6 +76,10 @@ protected function getHtml(HydePage $page): string
$contents = $page->compile();
}

if ($page instanceof BaseMarkdownPage && LiveEditController::enabled()) {
$contents = LiveEditController::injectLiveEditScript($contents);
}

return $contents;
}

Expand Down
4 changes: 4 additions & 0 deletions packages/realtime-compiler/tests/RealtimeCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

ob_start();

beforeEach(function () {
putenv('SERVER_LIVE_EDIT=false');
});

test('handle routes index page', function () {
putenv('SERVER_DASHBOARD=false');
mockRoute('');
Expand Down

0 comments on commit 9166d4e

Please sign in to comment.