design article title and add author virtual page

This commit is contained in:
isUnknown 2024-03-09 16:34:09 +01:00
parent 6fe73efbcf
commit 2114fbbb8e
12 changed files with 129 additions and 25 deletions

View file

@ -1,3 +1,10 @@
main.article {
margin-top: 0;
}
.article-header {
--margin-left: 2;
padding-left: calc(var(--unit--horizontal) * var(--margin-left));
margin-bottom: calc(var(--unit--vertical) * 4);
width: calc(100% - (var(--margin-left) * var(--unit--horizontal)));
}

View file

@ -33,8 +33,20 @@ button,
line-height: calc(var(--unit--vertical));
}
.fs-s {
font-size: var(--font-size-s) !important;
}
.fs-m {
font-size: var(--font-size-m) !important;
}
.fs-l {
font-size: var(--font-size-l) !important;
}
.fs-xl {
font-size: var(--font-size-xl);
font-size: var(--font-size-xl) !important;
}
.fs-xxl {
font-size: var(--font-size-xxl) !important;
}
.title-center {
@ -44,6 +56,13 @@ button,
width: 100%;
}
.main-title {
line-height: 1;
text-align: left;
box-sizing: border-box;
margin-bottom: 1rem;
}
p,
li,
button,

View file

@ -10,9 +10,10 @@
--unit--vertical: 1.7rem;
--font-size-s: 0.8rem;
--font-size-m: 1.2rem;
--font-size-l: 1.5rem;
--font-size-xl: 3.7rem;
--font-size-m: calc(var(--font-size-s) * 1.5);
--font-size-l: calc(var(--font-size-m) * 1.5);
--font-size-xl: calc(var(--font-size-l) * 1.5);
--font-size-xxl: calc(var(--font-size-xl) * 1.5);
--font-weight-light: 200;
--font-weight-bold: 400;

View file

@ -7,6 +7,7 @@ columns:
- width: 1/3
sections:
texts:
label: Textes
type: pages
templates:
- linear

View file

@ -3,12 +3,6 @@ description: Un administrateur a tous les droits.
image:
icon: star-filled
columns:
- width: 1/2
fields:
link:
label: Lien
- width: 1/2
fields:
fields:
presentation:
type: writer

View file

@ -19,12 +19,6 @@ permissions:
users:
*: false
columns:
- width: 1/2
fields:
link:
label: Lien
- width: 1/2
fields:
fields:
presentation:
type: writer

View file

@ -1,5 +1,7 @@
<?php
use Kirby\Uuid\Uuid;
return [
'debug' => true,
'panel' => [
@ -44,5 +46,25 @@ return [
'comments',
'system'
]
],
'routes' => [
[
'pattern' => 'auteur/(:any)',
'action' => function ($slug) {
$kirby = kirby();
$author = getAuthorBySlug($slug);
return Page::factory([
'slug' => '',
'template' => 'author',
'model' => 'authors',
'content' => [
'title' => $author->name(),
'presentation' => $author->presentation(),
'uuid' => Uuid::generate(),
]
]);
}
]
]
];

View file

@ -0,0 +1,37 @@
<?php
function setTitleFontSizeClass($title, $level = 'h1')
{
$length = strlen($title);
if ($level === 'h1') {
switch (true) {
case ($length < 35):
return 'fs-xxl';
break;
case ($length < 70):
return 'fs-xl';
break;
default:
return 'fs-l';
break;
}
}
}
function getAuthorBySlug($slug)
{
$kirby = kirby();
$author = '';
foreach ($kirby->users() as $user) {
if (Str::slug($user->name()) === $slug) {
$author = $user;
}
}
return $author;
}

View file

@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?= $site->title() ?><?= e($page->url() !== $site->url(), '-' . $page->title()) ?></title>
<link rel="stylesheet" href="<?= url('assets') ?>/css/style.css" />
<link rel="stylesheet" href="<?= url('assets') ?>/css/style.css?version-cache-prevent<?= rand(0, 1000)?>" />
<script src="<?= url('assets') ?>/js/script.js" defer></script>
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
<meta name="robots" content="noindex">

24
site/templates/author.php Normal file
View file

@ -0,0 +1,24 @@
<?php snippet('header'); ?>
<header id="header" class="minimized">
<div id="logo" >
<a href="/" class="no-line">
<h2 id="actuel">actuel</h2>
<h2 id="inactuel">inactuel</h2>
</a>
</div>
</header>
<main id="<?= $page->template() ?>">
<article>
<div class="article-header">
<h1 class="main-title title-center <?= setTitleFontSizeClass($page->title()) ?>"><?= $page->title() ?></h1>
<p></p>
</div>
<?php snippet('tabs', [
'left' => [
'label' => 'Présentation',
'content' => $page->presentation()
]
]) ?>
</article>
</main>

View file

@ -8,13 +8,18 @@
</div>
</header>
<main id="<?= $page->template() ?>">
<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>
</div>
<?php snippet('tabs', [
'left' => [
'label' => 'Édito ' . $page->parent()->title(),
'content' => $page->parent()->edito()
]
]) ?>
<h1 class="title-center"><?= $page->title() ?></h1>
</article>
</main>
<?php snippet('footer') ?>