From fc267d80d12dfcb076fa66834e2b8fa6bcb22e1a Mon Sep 17 00:00:00 2001 From: isUnknown Date: Mon, 3 Feb 2025 16:32:36 +0100 Subject: [PATCH] fix #15 --- assets/css/src/article.css | 8 +++ site/config/routes/virtual-category.php | 19 +++--- site/models/category.php | 23 +++++++ site/templates/category.php | 88 +++++++++++++++---------- site/templates/year.php | 23 +++++-- 5 files changed, 110 insertions(+), 51 deletions(-) create mode 100644 site/models/category.php diff --git a/assets/css/src/article.css b/assets/css/src/article.css index 10bd7a9..e31ea9a 100644 --- a/assets/css/src/article.css +++ b/assets/css/src/article.css @@ -9,6 +9,14 @@ article #main-content { font-style: italic; } +#main-content .texts { + margin-top: calc(2 * var(--unit--vertical)); +} + +#main-content .see-more { + margin-top: calc(var(--unit--vertical) * 0.5); +} + #chapo em { font-style: normal; } diff --git a/site/config/routes/virtual-category.php b/site/config/routes/virtual-category.php index 95b525c..37bb2fe 100644 --- a/site/config/routes/virtual-category.php +++ b/site/config/routes/virtual-category.php @@ -1,3 +1,4 @@ + 'categories/(:any)', 'action' => function ($category) { - $kirby = kirby(); - - return Page::factory( - [ - 'slug' => '', - 'template' => 'category', - 'model' => 'categories', - 'content' => [ + return Page::factory([ + 'slug' => Str::slug($category) . '-' . Uuid::generate(), + 'template' => 'category', + 'model' => 'category', + 'content' => [ 'title' => $category, 'uuid' => Uuid::generate(), - ] - ] - ); + ], + ]); } ]; diff --git a/site/models/category.php b/site/models/category.php new file mode 100644 index 0000000..bb60265 --- /dev/null +++ b/site/models/category.php @@ -0,0 +1,23 @@ +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 6111077..e55c9a5 100644 --- a/site/templates/category.php +++ b/site/templates/category.php @@ -1,36 +1,58 @@ - - +
-
- - - - -

title() ?>

+
+ true), slots: true) ?> + +

title() ?>

+ + + +
+ edito()->isNotEmpty()): ?> +
+ edito() ?> +
+ + + children() as $article): ?> +
  • + +

    title() ?>

    +
    +
    +

    + par + author()->toPage()->title(); + } catch (\Throwable $th) { + throw new Exception(json_encode($article->author()), 1); + + } + ?> + author()->toPage()->title() ?>
    + publiƩ le published()->toDate('d/m/Y') ?>
    + dans parent()->title() ?> / category() ?> +

    +
    +
  • - - -
    -
    \ No newline at end of file + + + + + \ No newline at end of file diff --git a/site/templates/year.php b/site/templates/year.php index 01861cb..225f0b9 100644 --- a/site/templates/year.php +++ b/site/templates/year.php @@ -4,20 +4,29 @@ true), slots: true) ?>

    title() ?>

    - subtitle()->isNotEmpty()): ?> -

    subtitle()->inline() ?>

    -

    ouverte depuis le openDate()->toDate('d/m/Y') ?>

    -
    - chapo()->isNotEmpty()): ?> -
    - chapo() ?> +
    + edito()->isNotEmpty()): ?> +
    + edito() ?>
    +
      children() as $article): ?>