FEATURE Refactoring and optimizing functionnal behaviour

This commit is contained in:
Nonimart 2025-06-25 11:45:16 +02:00
parent 435eb4f218
commit 86fd29864c
2 changed files with 32 additions and 19 deletions

View File

@ -0,0 +1,32 @@
<?php
$postId = $args['postId'];
$isArticle = is_singular('articles');
$componentTitle = $isArticle ? 'Auteur·e·s de l\'article' : 'Auteur·e·s de la revue';
$articleTitle = get_the_title($postId);
$authors = [];
if ($isArticle) {
$authors = get_field('authors', $postId);
} else {
$authors = getRevueAuthors($postId);
}
if (empty($authors)) return;
?>
<section class="revue-authors-list">
<h3 class="revue-authors-list__title"><?php echo $componentTitle; ?></h3>
<?php if ($articleTitle) : ?>
<p class="revue-authors-list__article-title"><?php echo $articleTitle; ?></p>
<?php endif; ?>
<?php foreach ($authors as $authorID) : ?>
<?php get_template_part(
'template-parts/authors/card-author',
null,
array(
'ID' => $authorID,
)
); ?>
<?php endforeach; ?>
</section>

View File

@ -1,19 +0,0 @@
<?php
$revueID = $args['revueID'];
$authors = getRevueAuthors($revueID);
?>
<section class="revue-authors-list">
<h3 class="revue-authors-list__title">Auteur·e·s de la revue</h3>
<?php foreach ($authors as $authorID) : ?>
<?php get_template_part(
'template-parts/authors/card-author',
null,
array(
'ID' => $authorID,
)
); ?>
<?php endforeach; ?>
</section>