Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Group templates by name for block themes (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
QWp6t committed Nov 6, 2024
1 parent b1c7e9d commit ede407b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Roots/Acorn/Sage/Concerns/FiltersTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Roots\Acorn\Sage\Concerns;

use Illuminate\Support\Str;

trait FiltersTemplates
{
/**
Expand Down Expand Up @@ -35,7 +37,12 @@ public function filterTemplateHierarchy($files)
$templates = array_diff($templates, $pages);
}

return [...$pages, ...$files, ...$templates];
return collect([...$pages, ...$files, ...$templates])
->groupBy(function ($item) {
return Str::of($item)->afterLast('/')->before('.');
})
->flatten()
->toArray();
}

/**
Expand Down

0 comments on commit ede407b

Please sign in to comment.