diff --git a/routes/fallback.php b/routes/fallback.php index 993cb85..a62824d 100644 --- a/routes/fallback.php +++ b/routes/fallback.php @@ -1,10 +1,4 @@ path())->toResponse(request())) { - if (View::exists($entry->get('template'))) { - echo view($entry->get('template'), $entry); - } else if (View::exists(str($entry->structure()->handle())->singular()->toString())) { - echo view(str($entry->structure()->handle())->singular()->toString(), $entry); - } -} +$controller = new Rapidez\Statamic\Http\Controllers\StatamicRewriteController(); +$controller(request()); diff --git a/src/Http/Controllers/StatamicRewriteController.php b/src/Http/Controllers/StatamicRewriteController.php new file mode 100644 index 0000000..1927dea --- /dev/null +++ b/src/Http/Controllers/StatamicRewriteController.php @@ -0,0 +1,22 @@ +where('collection', 'pages') + ->where('slug', $request->path() == '/' ? 'home' : $request->path()) + ->first(); + + $template = View::exists($entry->get('template')) ? $entry->get('template') : $entry->blueprint->handle(); + + echo view($template, ['entry' => $entry]); + } +}