fix category page

This commit is contained in:
isUnknown 2025-02-21 13:24:06 +01:00
parent a1d945a8ab
commit 7f661597ba
4 changed files with 11 additions and 7 deletions

View file

@ -11,13 +11,17 @@ return [
fn($text) => Str::slug($text->category()) === $category fn($text) => Str::slug($text->category()) === $category
); );
$children = new Pages(); $texts = [];
foreach ($textsInCategory as $text) { foreach ($textsInCategory as $text) {
$children->add($text); $texts[] = (string) $text->uri();
} }
$title = $textsInCategory->first()->category(); try {
$title = $textsInCategory->first()->category();
} catch (\Throwable $th) {
go('/erreur');
}
return Page::factory([ return Page::factory([
'slug' => Str::slug($category) . '-' . Uuid::generate(), 'slug' => Str::slug($category) . '-' . Uuid::generate(),
@ -25,9 +29,9 @@ return [
'model' => 'category', 'model' => 'category',
'content' => [ 'content' => [
'title' => $title, 'title' => $title,
'texts' => Yaml::encode($texts),
'uuid' => Uuid::generate(), 'uuid' => Uuid::generate(),
], ],
'children' => $children->toArray(),
]); ]);
}, },
]; ];

View file

@ -34,7 +34,7 @@
<span class="light">dans</span> <a <span class="light">dans</span> <a
href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a>
/ <a / <a
href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a> href="/categories/<?= Str::slug($article->category()) ?>"><?= $article->category() ?></a>
</p> </p>
</div> </div>
</li> </li>

View file

@ -52,7 +52,7 @@
<span class="light">dans</span> <a <span class="light">dans</span> <a
href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a>
/ <a / <a
href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a> href="/categories/<?= Str::slug($article->category()) ?>"><?= $article->category() ?></a>
</p> </p>
</div> </div>
</li> </li>

View file

@ -14,7 +14,7 @@
@click="edito = !edito">Lire</button> @click="edito = !edito">Lire</button>
<?php endif ?> <?php endif ?>
<ul class="texts"> <ul class="texts">
<?php foreach($page->children() as $article): ?> <?php foreach($page->texts()->toPages() as $article): ?>
<li class="text"> <li class="text">
<a href="<?= $article->url() ?>" <a href="<?= $article->url() ?>"
class="text__title no-underline"> class="text__title no-underline">