Skip to content

Commit

Permalink
Only show collection in nav when collection is configured for selecte…
Browse files Browse the repository at this point in the history
…d site
  • Loading branch information
duncanmcclean committed Jan 15, 2024
1 parent 6144f0c commit bfdeac9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/CP/Navigation/CoreNav.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Statamic\Facades\GlobalSet as GlobalSetAPI;
use Statamic\Facades\Nav as NavAPI;
use Statamic\Facades\Role as RoleAPI;
use Statamic\Facades\Site;
use Statamic\Facades\Stache;
use Statamic\Facades\Taxonomy as TaxonomyAPI;
use Statamic\Facades\UserGroup as UserGroupAPI;
Expand Down Expand Up @@ -65,11 +66,13 @@ protected function makeContentSection()
->icon('/content-writing')
->can('index', Collection::class)
->children(function () {
return CollectionAPI::all()->sortBy->title()->map(function ($collection) {
return Nav::item($collection->title())
->url($collection->showUrl())
->can('view', $collection);
});
return CollectionAPI::all()->sortBy->title()
->filter(fn ($collection) => $collection->sites()->contains(Site::selected()->handle()))
->map(function ($collection) {
return Nav::item($collection->title())
->url($collection->showUrl())
->can('view', $collection);
});
});

Nav::content('Navigation')
Expand Down

0 comments on commit bfdeac9

Please sign in to comment.