Skip to content

Commit

Permalink
improve nova integration (statamic#3543)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga authored Apr 19, 2021
1 parent 141466a commit a9ff5a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
* All front-end website requests go through a single controller method.
*/
Route::any('/{segments?}', 'FrontendController@index')
->where('segments', '.*')
->where('segments', Statamic::frontendRouteSegmentRegex())
->name('statamic.site');
}
12 changes: 12 additions & 0 deletions src/Statamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Illuminate\Http\Request;
use Laravel\Nova\Nova;
use Statamic\Facades\File;
use Statamic\Facades\Site;
use Statamic\Facades\URL;
Expand Down Expand Up @@ -300,4 +301,15 @@ public static function repository($abstract, $concrete)
app()->bind($abstract, $concrete);
}
}

public static function frontendRouteSegmentRegex()
{
$prefix = '';

if (class_exists(Nova::class)) {
$prefix = '(?!'.trim(Nova::path(), '/').')';
}

return $prefix.'.*';
}
}

0 comments on commit a9ff5a0

Please sign in to comment.