fix category page
This commit is contained in:
parent
18db74998d
commit
a1d945a8ab
5 changed files with 51 additions and 69 deletions
|
|
@ -59,11 +59,15 @@ main article > div {
|
||||||
transform: translateX(-1px) translateY(-1px) !important;
|
transform: translateX(-1px) translateY(-1px) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.page-cover,
|
||||||
|
article > h1 {
|
||||||
|
padding-top: calc(50vw);
|
||||||
|
}
|
||||||
|
|
||||||
.page-cover {
|
.page-cover {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 100svh;
|
height: 100svh;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding-top: calc(50vw);
|
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
@ -142,8 +146,11 @@ button.toggle.right::before {
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-cover {
|
.page-cover,
|
||||||
|
article > h1 {
|
||||||
padding-top: 15vw;
|
padding-top: 15vw;
|
||||||
|
}
|
||||||
|
.page-cover {
|
||||||
min-height: calc(22 * var(--unit--vertical));
|
min-height: calc(22 * var(--unit--vertical));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Kirby\Uuid\Uuid;
|
use Kirby\Uuid\Uuid;
|
||||||
|
|
@ -6,14 +5,29 @@ use Kirby\Uuid\Uuid;
|
||||||
return [
|
return [
|
||||||
'pattern' => 'categories/(:any)',
|
'pattern' => 'categories/(:any)',
|
||||||
'action' => function ($category) {
|
'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([
|
return Page::factory([
|
||||||
'slug' => Str::slug($category) . '-' . Uuid::generate(),
|
'slug' => Str::slug($category) . '-' . Uuid::generate(),
|
||||||
'template' => 'category',
|
'template' => 'category',
|
||||||
'model' => 'category',
|
'model' => 'category',
|
||||||
'content' => [
|
'content' => [
|
||||||
'title' => $category,
|
'title' => $title,
|
||||||
'uuid' => Uuid::generate(),
|
'uuid' => Uuid::generate(),
|
||||||
],
|
],
|
||||||
|
'children' => $children->toArray(),
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Kirby\Cms\Pages;
|
|
||||||
use Kirby\Cms\Page;
|
|
||||||
use Kirby\Uuid\Uuid;
|
|
||||||
|
|
||||||
class CategoryPage extends Page
|
|
||||||
{
|
|
||||||
public function children(): Pages
|
|
||||||
{
|
|
||||||
$category = $this->title()->value();
|
|
||||||
$allTexts = page("textes")->grandChildren();
|
|
||||||
$textsInCategory = $allTexts->filterBy('category', $category);
|
|
||||||
|
|
||||||
$children = new Pages();
|
|
||||||
|
|
||||||
foreach ($textsInCategory as $text) {
|
|
||||||
$children->add($text);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,56 +1,40 @@
|
||||||
<?php snippet('header') ?>
|
<?php snippet('header') ?>
|
||||||
<main id="<?= $page->template() ?>">
|
<main id="<?= $page->template() ?>">
|
||||||
<article>
|
<article>
|
||||||
<?php snippet('cover', array('isOpen' => true), slots: true) ?>
|
<h1 class="main-title"><?= $page->title() ?></h1>
|
||||||
<?php slot('title') ?>
|
|
||||||
<h1 class="main-title"><?= $page->title() ?></h1>
|
<div id="main-content" x-data="{
|
||||||
<?php endslot() ?>
|
|
||||||
<?php endsnippet() ?>
|
|
||||||
|
|
||||||
<div id="main-content"
|
|
||||||
x-data="{
|
|
||||||
edito: false
|
edito: false
|
||||||
}"
|
}">
|
||||||
>
|
<?php if ($page->edito()->isNotEmpty()): ?>
|
||||||
<?php if ($page->edito()->isNotEmpty()): ?>
|
<div id="edito" :class="edito ? '' : 'short'">
|
||||||
<div
|
<?= $page->edito() ?>
|
||||||
id="edito"
|
</div>
|
||||||
:class="edito ? '' : 'short'"
|
<button :class="edito ? 'open' : 'close'" class="see-more toggle-btn toggle-btn--left"
|
||||||
>
|
@click="edito = !edito">Lire</button>
|
||||||
<?= $page->edito() ?>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
:class="edito ? 'open' : 'close'"
|
|
||||||
class="see-more toggle-btn toggle-btn--left"
|
|
||||||
@click="edito = !edito"
|
|
||||||
>Lire</button>
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<ul class="texts">
|
<ul class="texts">
|
||||||
<?php foreach($page->children() as $article): ?>
|
<?php foreach($page->children() as $article): ?>
|
||||||
<li
|
<li class="text">
|
||||||
class="text"
|
<a href="<?= $article->url() ?>"
|
||||||
>
|
class="text__title no-underline">
|
||||||
<a href="<?= $article->url() ?>" class="text__title no-underline">
|
|
||||||
<h4><?= $article->title() ?></h4>
|
<h4><?= $article->title() ?></h4>
|
||||||
</a>
|
</a>
|
||||||
<div class="text__infos">
|
<div class="text__infos">
|
||||||
<p>
|
<p>
|
||||||
<span class="light">par</span>
|
<span class="light">par</span>
|
||||||
<?php
|
<a class="author"
|
||||||
try {
|
href="/auteurs/<?= Str::slug($article->author()->toPage()->title()) ?>"><?= $article->author()->toPage()->title() ?></a><br>
|
||||||
echo $article->author()->toPage()->title();
|
<span class="light">publié le
|
||||||
} catch (\Throwable $th) {
|
</span><?= $article->published()->toDate('d/m/Y') ?><br>
|
||||||
throw new Exception(json_encode($article->author()), 1);
|
<span class="light">dans</span> <a
|
||||||
|
href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a>
|
||||||
}
|
/ <a
|
||||||
?>
|
href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
|
||||||
<a class="author" href="/auteurs/<?= Str::slug($article->author()->toPage()->title()) ?>"><?= $article->author()->toPage()->title() ?></a><br>
|
|
||||||
<span class="light">publié le </span><?= $article->published()->toDate('d/m/Y') ?><br>
|
|
||||||
<span class="light">dans</span> <a href="<?= $article->parent()->url() ?>"><?= $article->parent()->title() ?></a> / <a href="/categories/<?= $article->category() ?>"><?= $article->category() ?></a>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</main>
|
</main>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
<span class="light">dans</span> <a
|
<span class="light">dans</span> <a
|
||||||
href="<?= $page->parent()->url() ?>"
|
href="<?= $page->parent()->url() ?>"
|
||||||
title="voir les textes liés à l'année <?= $page->parent()->title() ?>"><?= $page->parent()->title() ?></a>
|
title="voir les textes liés à l'année <?= $page->parent()->title() ?>"><?= $page->parent()->title() ?></a>
|
||||||
/ <a href="/categories/<?= $page->category() ?>"
|
/ <a href="/categories/<?= Str::slug($page->category()) ?>"
|
||||||
title="voir les textes de la catégorie <?= $page->category() ?>"><?= $page->category() ?></a>
|
title="voir les textes de la catégorie <?= $page->category() ?>"><?= $page->category() ?></a>
|
||||||
</p>
|
</p>
|
||||||
<?php endslot() ?>
|
<?php endslot() ?>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue