FEATURE Otpimizing author single
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Nonimart 2025-09-25 15:13:39 +02:00
parent 0c8334e4c1
commit 2d8241ede0
5 changed files with 185 additions and 42 deletions

View File

@ -38,6 +38,13 @@ function getRevueAuthors($revueID)
return array_unique($authors); return array_unique($authors);
} }
function get_author_articles_amount($authorID)
{
if (empty($authorID)) return 0;
$articles = count_user_articles($authorID, 'articles');
return $articles;
}
/** /**
* Récupère tous les termes uniques d'une taxonomie pour une revue * Récupère tous les termes uniques d'une taxonomie pour une revue
* *

View File

@ -1,31 +1,88 @@
.page--single-auteurs { .page--single-auteurs {
@apply max-w-screen-xl mx-auto px-4; @apply max-w-screen-xl mx-auto px-4;
h1 {
@apply !text-8xl uppercase mb-8 col-span-2;
}
.author-card__profile-picture {
@apply block static col-span-2 lg:col-span-1;
}
&__header { &__header {
@apply grid grid-cols-1 gap-2 gap-x-8 items-center justify-center py-12; @apply py-12 !my-0 bg-primary alignfull pb-80;
h1 {
@apply !text-6xl uppercase mb-8 col-span-2 !text-white;
}
p {
@apply text-white;
}
@screen lg { .inner {
grid-template-columns: auto 1fr; @apply mx-auto flex flex-col lg:flex-row gap-24 justify-center items-center max-w-screen-xl;
}
.sub-infos {
@apply text-lg text-white flex gap-2 py-4;
.data-type {
@apply uppercase font-medium text-xl tracking-widest;
}
.articles-amount {
@apply flex items-center gap-2;
&::before {
content: '';
@apply block w-6 h-6 bg-no-repeat bg-center;
background-image: url('../resources/img/icons/icon-activites.svg');
background-size: contain;
}
}
}
.author-card__profile-picture {
@apply block col-span-2 lg:col-span-1 relative z-10 w-48 h-48 p-0;
.profile-picture-container {
@apply relative z-10 w-full h-full bg-white p-4;
z-index: 2;
}
.background-picture {
@apply absolute inset-0 w-full h-full bg-white;
z-index: -1;
transform: translate(30px, 30px) rotate(5deg);
&:after {
content: '';
@apply absolute inset-0 w-full h-full bg-carhop-green-100;
z-index: 2;
top: 1rem;
left: 1rem;
width: calc(100% - 2rem);
height: calc(100% - 2rem);
}
}
}
.infos {
@apply max-w-screen-md;
} }
} }
&__comities-list { &__comities-list {
@apply flex flex-wrap gap-2 items-center col-span-2 text-primary font-normal pt-4; @apply flex flex-wrap gap-2 items-center col-span-2 text-primary font-normal pt-4;
} }
&__comity { &__comity {
@apply text-lg fjalla uppercase; @apply text-lg flex items-center gap-2 font-light tracking-wide;
&:before {
@apply content-[''] block w-6 h-6 bg-no-repeat bg-center;
background-size: contain;
}
+ .page--single-auteurs__comity { + .page--single-auteurs__comity {
@apply before:content-['|'] before:mx-2 before:text-primary; @apply before:content-['|'] before:mx-2 before:text-primary;
} }
} &--redaction {
&__comities-list-title { &:before {
@apply text-base font-normal text-neutral-400; background-image: url('../resources/img/icons/carhop-plume-white.svg');
}
}
}
&__latest-publication {
transform: translateY(-200px);
margin-bottom: -150px;
p {
@apply text-white uppercase text-xl font-semibold tracking-widest mb-8;
}
} }
} }

View File

@ -0,0 +1,12 @@
<svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1328_11789)">
<path d="M24.6411 4.88879L22.2345 6.53778V15.3777L7.16797 23.8166L8.99849 7.32024L16.9158 3.09753L17.0438 0.0258789" stroke="white" stroke-width="2"/>
<path d="M7.16797 23.8166L13.4084 14.3753" stroke="white" stroke-width="2"/>
<path d="M0 24.3533H7.16846" stroke="white" stroke-width="2"/>
</g>
<defs>
<clipPath id="clip0_1328_11789">
<rect width="25" height="25" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 542 B

View File

@ -0,0 +1,12 @@
<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1328_11790)">
<path d="M17.5859 18.5605L23.3362 24.3354" stroke="white" stroke-width="2"/>
<path d="M10.7539 21.4526C16.1775 21.4526 20.5742 16.8598 20.5742 11.1943C20.5742 5.52879 16.1775 0.935974 10.7539 0.935974C5.33029 0.935974 0.933594 5.52879 0.933594 11.1943C0.933594 16.8598 5.33029 21.4526 10.7539 21.4526Z" stroke="white" stroke-width="2" stroke-miterlimit="10"/>
<path d="M10.7556 6.68164L6.25391 11.1954L10.7556 15.7091L15.2573 11.1954L10.7556 6.68164Z" stroke="white" stroke-width="2" stroke-miterlimit="10"/>
</g>
<defs>
<clipPath id="clip0_1328_11790">
<rect width="24" height="25" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 760 B

View File

@ -7,7 +7,7 @@ $profilePicture = get_field('profile_thumbnail', $author_id);
$profilePictureUrl = $profilePicture['url'] ?? ''; $profilePictureUrl = $profilePicture['url'] ?? '';
$profilePictureAlt = $profilePicture['alt'] ?? ''; $profilePictureAlt = $profilePicture['alt'] ?? '';
$comity = get_field('comity', $author_id); $comity = get_field('comity', $author_id);
$articlesAmount = get_author_articles_amount($author_id);
?> ?>
@ -19,10 +19,9 @@ $comity = get_field('comity', $author_id);
<div class="page--single-auteurs__header"> <div class="page--single-auteurs__header">
<div class="inner container">
<h1 class="page--single-auteurs__title"><?php the_title(); ?></h1>
<div class="author-card__profile-picture"> <div class="author-card__profile-picture">
<div class="profile-picture-container">
<?php if ($profilePictureUrl) : ?> <?php if ($profilePictureUrl) : ?>
<img src="<?php echo $profilePictureUrl; ?>" alt="<?php echo $profilePictureAlt; ?>"> <img src="<?php echo $profilePictureUrl; ?>" alt="<?php echo $profilePictureAlt; ?>">
<?php else : ?> <?php else : ?>
@ -31,13 +30,29 @@ $comity = get_field('comity', $author_id);
</div> </div>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="background-picture"></div>
</div>
<div class="author-card__content">
<p class="page--single-auteurs__subinfo sub-infos">
<span class="data-type">Auteur·e</span>
<?php if ($articlesAmount) : ?>
<span class="articles-amount">
<?php echo $articlesAmount; ?> articles
</span>
<?php endif; ?>
</p>
<h1 class="page--single-auteurs__title"><?php the_title(); ?></h1>
<div class="infos"> <div class="infos">
<p><?php echo $description; ?></p> <p><?php echo $description; ?></p>
<?php if ($comity) : ?> <?php if ($comity) : ?>
<p class="page--single-auteurs__comities-list"> <p class="page--single-auteurs__comities-list">
<span class="page--single-auteurs__comities-list-title">
membre de :
</span>
<?php foreach ($comity as $comity_value) : ?> <?php foreach ($comity as $comity_value) : ?>
<?php <?php
$comities = get_field_object('comity'); $comities = get_field_object('comity');
@ -45,7 +60,7 @@ $comity = get_field('comity', $author_id);
?> ?>
<?php if ($comity_label) : ?> <?php if ($comity_label) : ?>
<span class="page--single-auteurs__comity"><?php echo $comity_label ?></span> <span class="page--single-auteurs__comity page--single-auteurs__comity--<?php echo $comity_value ?>"><?php echo $comity_label ?></span>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
</p> </p>
@ -54,13 +69,53 @@ $comity = get_field('comity', $author_id);
</div> </div>
</div>
</div>
</div>
<div class="page--single-auteurs__latest-publication">
<p>Dernière publication</p>
<?php
$latestArticle = get_posts(array(
'post_type' => 'articles',
'posts_per_page' => 1,
'orderby' => 'date',
'order' => 'DESC',
'post_not_in' => array(913),
'meta_query' => array(
array(
'key' => 'authors',
'value' => $author_id,
'compare' => 'LIKE'
)
),
));
if (isset($latestArticle[0])) : ?>
<?php
get_template_part('template-parts/dynamiques/article-card', null, array(
'ID' => $latestArticle[0]->ID,
'showCover' => true,
));
?>
<?php endif; ?>
</div> </div>
<?php <?php
$authorArticles = get_posts(array( $authorArticles = get_posts(array(
'post_type' => 'articles', 'post_type' => 'articles',
'posts_per_page' => -1, 'posts_per_page' => -1,
'post__not_in' => array($latestArticle[0]->ID),
'meta_query' => array( 'meta_query' => array(
array( array(
'key' => 'authors', // Ajustez selon votre structure 'key' => 'authors', // Ajustez selon votre structure