diff --git a/packages/realtime-compiler/src/Routing/PageRouter.php b/packages/realtime-compiler/src/Routing/PageRouter.php index 1aadd3f1d38..1e41b531bd4 100644 --- a/packages/realtime-compiler/src/Routing/PageRouter.php +++ b/packages/realtime-compiler/src/Routing/PageRouter.php @@ -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; @@ -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; } diff --git a/packages/realtime-compiler/tests/RealtimeCompilerTest.php b/packages/realtime-compiler/tests/RealtimeCompilerTest.php index 981f4b53df5..9f48e9467a9 100644 --- a/packages/realtime-compiler/tests/RealtimeCompilerTest.php +++ b/packages/realtime-compiler/tests/RealtimeCompilerTest.php @@ -17,6 +17,10 @@ ob_start(); +beforeEach(function () { + putenv('SERVER_LIVE_EDIT=false'); +}); + test('handle routes index page', function () { putenv('SERVER_DASHBOARD=false'); mockRoute('');