add author page

This commit is contained in:
isUnknown 2024-03-09 17:06:24 +01:00
parent 2114fbbb8e
commit f9397935bd
4 changed files with 26 additions and 18 deletions

View file

@ -49,7 +49,7 @@ return [
],
'routes' => [
[
'pattern' => 'auteur/(:any)',
'pattern' => 'auteurs/(:any)',
'action' => function ($slug) {
$kirby = kirby();
$author = getAuthorBySlug($slug);
@ -61,6 +61,7 @@ return [
'content' => [
'title' => $author->name(),
'presentation' => $author->presentation(),
'author' => $author->name(),
'uuid' => Uuid::generate(),
]
]);

View file

@ -1,5 +1,6 @@
<?php
$left['slug'] = Str::slug($left['label']);
$authorFilter = isset($authorFilter) ? $authorFilter : false;
?>
<div id="tabs" x-data="{
@ -31,21 +32,26 @@ $left['slug'] = Str::slug($left['label']);
<h3 class="fs-xl color" style="--color:var(--color-secondary)"><?= $year->title() ?></h3>
</div>
<?php foreach($year->children() as $article): ?>
<?php if (!$authorFilter || $authorFilter == $article->author()->toUser()->name()->value()) : ?>
<li class="article | bottom" style="--bottom:3">
<a href="<?= $article->url() ?>" class="article__title no-line">
<h3><?= $article->title() ?></h3>
</a>
<div class="article__infos">
<p>
<span class="opacity" style="--opacity:.5">Par</span>
<a class="author no-line" href="#"><?= $article->author()->toUser()->name() ?></a>,
<span class="opacity" style="--opacity:.5">le</span> <?= $article->published()->toDate('d/m/Y') ?>
<?php if (!$authorFilter): ?>
<span class="opacity" style="--opacity:.5">par</span>
<a class="author no-line" href="/auteurs/<?= Str::slug($article->author()->toUser()->name()) ?>"><?= $article->author()->toUser()->name() ?></a>,
<span class="opacity" style="--opacity:.5">le</span>
<?php endif ?>
<?= $article->published()->toDate('d/m/Y') ?>
</p>
</div>
<!-- <div class="article__labels">
<button class="label label--category">[ <?= $article->category() ?> ]</button>
</div> -->
</li>
<?php endif ?>
<?php endforeach ?>
<?php endforeach ?>
</ul>

View file

@ -18,7 +18,8 @@
'left' => [
'label' => 'Présentation',
'content' => $page->presentation()
]
],
'authorFilter' => $page->author()
]) ?>
</article>
</main>

View file

@ -11,7 +11,7 @@
<article>
<div class="article-header">
<h1 class="main-title title-center <?= setTitleFontSizeClass($page->title()) ?>"><?= $page->title() ?></h1>
<p>Par <a href="/auteur/<?= Str::slug($page->author()->toUser()->name()) ?>" title="Voir les articles d'<?= $page->author()->toUser()->name() ?>"><?= $page->author()->toUser()->name() ?></a></p>
<p><span class="opacity" style="--opacity:.5">par</span> <a class="author no-line" href="/auteurs/<?= Str::slug($page->author()->toUser()->name()) ?>" title="Voir les articles d'<?= $page->author()->toUser()->name() ?>"><?= $page->author()->toUser()->name() ?></a></p>
</div>
<?php snippet('tabs', [
'left' => [