fix category page
This commit is contained in:
parent
18db74998d
commit
a1d945a8ab
5 changed files with 51 additions and 69 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
<?php
|
||||
|
||||
use Kirby\Uuid\Uuid;
|
||||
|
|
@ -6,14 +5,29 @@ use Kirby\Uuid\Uuid;
|
|||
return [
|
||||
'pattern' => 'categories/(:any)',
|
||||
'action' => function ($category) {
|
||||
|
||||
$allTexts = page('textes')->grandChildren();
|
||||
$textsInCategory = $allTexts->filter(
|
||||
fn($text) => Str::slug($text->category()) === $category
|
||||
);
|
||||
|
||||
$children = new Pages();
|
||||
|
||||
foreach ($textsInCategory as $text) {
|
||||
$children->add($text);
|
||||
}
|
||||
|
||||
$title = $textsInCategory->first()->category();
|
||||
|
||||
return Page::factory([
|
||||
'slug' => Str::slug($category) . '-' . Uuid::generate(),
|
||||
'template' => 'category',
|
||||
'model' => 'category',
|
||||
'content' => [
|
||||
'title' => $category,
|
||||
'title' => $title,
|
||||
'uuid' => Uuid::generate(),
|
||||
],
|
||||
'children' => $children->toArray(),
|
||||
]);
|
||||
}
|
||||
},
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue