From 7f661597baef4dd1edadd7958f1e187e78a845fa Mon Sep 17 00:00:00 2001
From: isUnknown
Date: Fri, 21 Feb 2025 13:24:06 +0100
Subject: [PATCH] fix category page
---
site/config/routes/virtual-category.php | 12 ++++++++----
site/snippets/nav__texts--all.php | 2 +-
site/snippets/nav__texts--collection.php | 2 +-
site/templates/category.php | 2 +-
4 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/site/config/routes/virtual-category.php b/site/config/routes/virtual-category.php
index 782e4d4..75023aa 100644
--- a/site/config/routes/virtual-category.php
+++ b/site/config/routes/virtual-category.php
@@ -11,13 +11,17 @@ return [
fn($text) => Str::slug($text->category()) === $category
);
- $children = new Pages();
+ $texts = [];
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([
'slug' => Str::slug($category) . '-' . Uuid::generate(),
@@ -25,9 +29,9 @@ return [
'model' => 'category',
'content' => [
'title' => $title,
+ 'texts' => Yaml::encode($texts),
'uuid' => Uuid::generate(),
],
- 'children' => $children->toArray(),
]);
},
];
diff --git a/site/snippets/nav__texts--all.php b/site/snippets/nav__texts--all.php
index c3b12bc..4f1b6a5 100644
--- a/site/snippets/nav__texts--all.php
+++ b/site/snippets/nav__texts--all.php
@@ -34,7 +34,7 @@
dans = $article->parent()->title() ?>
/ = $article->category() ?>
+ href="/categories/= Str::slug($article->category()) ?>">= $article->category() ?>
diff --git a/site/snippets/nav__texts--collection.php b/site/snippets/nav__texts--collection.php
index b9e46e8..692845a 100644
--- a/site/snippets/nav__texts--collection.php
+++ b/site/snippets/nav__texts--collection.php
@@ -52,7 +52,7 @@
dans = $article->parent()->title() ?>
/ = $article->category() ?>
+ href="/categories/= Str::slug($article->category()) ?>">= $article->category() ?>
diff --git a/site/templates/category.php b/site/templates/category.php
index 48f2878..bf96628 100644
--- a/site/templates/category.php
+++ b/site/templates/category.php
@@ -14,7 +14,7 @@
@click="edito = !edito">Lire
- children() as $article): ?>
+ texts()->toPages() as $article): ?>
-