Skip to content

Commit d4cb5ce

Browse files
committed
Create initial improved support for routing nested index pages
1 parent 3df8e0a commit d4cb5ce

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Hyde\Pages\Concerns\BaseMarkdownPage;
1111
use Hyde\Framework\Actions\StaticPageBuilder;
1212
use Hyde\RealtimeCompiler\Http\LiveEditController;
13+
use Hyde\Framework\Exceptions\RouteNotFoundException;
1314
use Hyde\Framework\Features\Documentation\DocumentationSearchPage;
1415
use Hyde\Pages\Concerns\HydePage;
1516
use Hyde\RealtimeCompiler\Concerns\InteractsWithLaravel;
@@ -98,6 +99,16 @@ protected function getPageFromRoute(): HydePage
9899
return new DocumentationSearchPage();
99100
}
100101

101-
return Routes::getOrFail($this->normalizePath($this->request->path))->getPage();
102+
try {
103+
return Routes::getOrFail($this->normalizePath($this->request->path))->getPage();
104+
} catch (RouteNotFoundException $exception) {
105+
$index = Routes::get($this->normalizePath($this->request->path).'/index');
106+
107+
if ($index) {
108+
return $index->getPage();
109+
}
110+
111+
throw $exception;
112+
}
102113
}
103114
}

0 commit comments

Comments
 (0)