From a1d945a8abc5a58f1f9dc881bc746244d739ee8e Mon Sep 17 00:00:00 2001 From: isUnknown Date: Fri, 21 Feb 2025 13:08:53 +0100 Subject: [PATCH] fix category page --- assets/css/src/header.css | 11 ++++- site/config/routes/virtual-category.php | 20 ++++++-- site/models/category.php | 23 --------- site/templates/category.php | 64 ++++++++++--------------- site/templates/linear.php | 2 +- 5 files changed, 51 insertions(+), 69 deletions(-) delete mode 100644 site/models/category.php diff --git a/assets/css/src/header.css b/assets/css/src/header.css index d1e5e03..f3e9ff7 100644 --- a/assets/css/src/header.css +++ b/assets/css/src/header.css @@ -59,11 +59,15 @@ main article > div { transform: translateX(-1px) translateY(-1px) !important; } +.page-cover, +article > h1 { + padding-top: calc(50vw); +} + .page-cover { position: relative; height: 100svh; box-sizing: border-box; - padding-top: calc(50vw); display: flex; flex-direction: column; @@ -142,8 +146,11 @@ button.toggle.right::before { height: 100vh; } - .page-cover { + .page-cover, + article > h1 { padding-top: 15vw; + } + .page-cover { min-height: calc(22 * var(--unit--vertical)); } diff --git a/site/config/routes/virtual-category.php b/site/config/routes/virtual-category.php index 37bb2fe..782e4d4 100644 --- a/site/config/routes/virtual-category.php +++ b/site/config/routes/virtual-category.php @@ -1,4 +1,3 @@ - '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(), ]); - } + }, ]; diff --git a/site/models/category.php b/site/models/category.php deleted file mode 100644 index bb60265..0000000 --- a/site/models/category.php +++ /dev/null @@ -1,23 +0,0 @@ -title()->value(); - $allTexts = page("textes")->grandChildren(); - $textsInCategory = $allTexts->filterBy('category', $category); - - $children = new Pages(); - - foreach ($textsInCategory as $text) { - $children->add($text); - } - - return $children; - } -} diff --git a/site/templates/category.php b/site/templates/category.php index e55c9a5..48f2878 100644 --- a/site/templates/category.php +++ b/site/templates/category.php @@ -1,56 +1,40 @@
- true), slots: true) ?> - -

title() ?>

- - - -
title() ?> + +
- edito()->isNotEmpty()): ?> -
- edito() ?> -
- + }"> + edito()->isNotEmpty()): ?> +
+ edito() ?> +
+
diff --git a/site/templates/linear.php b/site/templates/linear.php index 675eec9..beab9b3 100644 --- a/site/templates/linear.php +++ b/site/templates/linear.php @@ -17,7 +17,7 @@ dans parent()->title() ?> - / category() ?>