Compare commits

...

31 Commits

Author SHA1 Message Date
Antoine M
f3837404d7 STYLE updating imports
All checks were successful
continuous-integration/drone/push Build is passing
2026-03-20 17:07:53 +01:00
Antoine M
7e927e168e FEATURE Handling the information tab 2026-03-20 17:07:44 +01:00
Antoine M
4a054947f3 STYLE REfining style for wp-block-file 2026-03-20 17:07:28 +01:00
Antoine M
23eb4184af REFACTOR Moving the explore tags component from dynamiques theme to carhop theme 2026-03-20 17:06:57 +01:00
Antoine M
77de397e0c STYLE styling the native wp file component 2026-03-20 17:06:31 +01:00
Antoine M
e8e57aa7e9 STYLE Handling wptable folowed by h3 sequence 2026-03-20 17:06:10 +01:00
Antoine M
c4d0f66b5d STYLE Handling main author and publication directors style 2026-03-20 17:05:38 +01:00
Antoine M
34f1e27e3c STYLE Add framed background variant to content box and refine alignment styles 2026-03-20 17:05:17 +01:00
Antoine M
2e2df71ecd STYLE introducing component style 2026-03-20 17:04:57 +01:00
Antoine M
487e9f8abd STYLE Handling main author style 2026-03-20 17:04:43 +01:00
Antoine M
297f573507 REBUILDING 2026-03-20 17:04:20 +01:00
Antoine M
eb1a731ca9 STYLE Small refinments on subtitle big 2026-03-20 17:04:07 +01:00
Antoine M
5ffe427cc2 STYLE Handling variants, numerotations and mains authors 2026-03-20 17:03:54 +01:00
Antoine M
c101758371 FEATURE Handling the alignfull alignment 2026-03-20 17:03:35 +01:00
Antoine M
50a19fca8c STYLE Add margin-bottom utility to table block CSS 2026-03-20 17:03:07 +01:00
Antoine M
2ba5f40892 REFACTOR Moving author list component from dynamiques theme to carhop theme 2026-03-20 17:02:41 +01:00
Antoine M
213a4f078e REFACTOR Removing unecessary lineskip 2026-03-20 17:02:06 +01:00
Antoine M
ef0fafd101 Handling main authors, publication directors and showing hiding tags 2026-03-20 17:01:46 +01:00
Antoine M
257673bb2e FEATURE Add support for filtering posts by etiquette in post grid when page is loaded with a query var 2026-03-20 17:01:10 +01:00
Antoine M
1ff55bb638 CHORE Remove unnecessary whitespace in get_authors_linked_to_posts function 2026-03-20 16:59:57 +01:00
Antoine M
d0133e4aad REFACTOR Using a dedicated numerotation function 2026-03-20 16:59:43 +01:00
Antoine M
405097cbb0 FEATURE Handling dynamiques articles post type handling in hasPostTypeNumerotation function 2026-03-20 16:59:27 +01:00
Antoine M
b6bf2de725 REFACTOR Using a dedicated numerotation function 2026-03-20 16:58:27 +01:00
Antoine M
965f097507 FEATURE Handling active filters when page has query vars 2026-03-20 16:57:40 +01:00
Antoine M
86864d3132 FEATURE Introducing explor tags component in page 2026-03-20 16:56:15 +01:00
Antoine M
f06fe21a5a FEATURE Handling main authors in additions to author in buil posts query 2026-03-20 16:55:48 +01:00
Antoine M
7f6be681fe FEATURE Handling author status and status label 2026-03-20 16:54:50 +01:00
Antoine M
20398a32d9 FEATURE Handling mains authors and publication directors 2026-03-20 16:54:15 +01:00
Antoine M
8c5dd8cb02 FEATURE Handling main author 2026-03-20 16:53:55 +01:00
Antoine M
ea5e3b13cd FEATURE Handling new features in components like scrolling to filters if page var has query 2026-03-20 16:53:33 +01:00
Antoine M
13930d6449 UPLOAD Assets 2026-03-20 16:52:43 +01:00
31 changed files with 635 additions and 191 deletions

View File

@ -14,16 +14,16 @@ body {
#wp-submit {
--tw-border-opacity: 1;
border-color: rgb(19 111 99 / var(--tw-border-opacity, 1));
border-color: rgb(19 111 99 / var(--tw-border-opacity));
--tw-bg-opacity: 1;
background-color: rgb(19 111 99 / var(--tw-bg-opacity, 1));
background-color: rgb(19 111 99 / var(--tw-bg-opacity));
}
#nav a,
#backtoblog a {
/* color: var(--red) !important; */
--tw-text-opacity: 1;
color: rgb(19 111 99 / var(--tw-text-opacity, 1));
color: rgb(19 111 99 / var(--tw-text-opacity));
}
#loginform {
@ -32,6 +32,6 @@ body {
.wp-pwd span {
--tw-text-opacity: 1;
color: rgb(19 111 99 / var(--tw-text-opacity, 1));
color: rgb(19 111 99 / var(--tw-text-opacity));
/* color: var(--red) !important; */
}

View File

@ -13,7 +13,6 @@ add_action('rest_api_init', function () {
'callback' => 'build_posts',
'permission_callback' => '__return_true',
));
});
@ -26,7 +25,7 @@ function build_posts($request)
$auteur = esc_html($request->get_param('auteur'));
$sort_by = esc_html($request->get_param('sort_by'));
$recherche = esc_html($request->get_param('recherche'));
// Construire les arguments de la query WordPress
$args = array(
@ -73,14 +72,20 @@ function build_posts($request)
);
}
// Filtre par auteur
// Filtre par auteur (authors = relation multiple, main_author = auteur principal)
if (!empty($auteur) && $auteur != '1') {
$args['meta_query'] = array(
'relation' => 'OR',
array(
'key' => 'authors', // Ajustez selon votre structure
'key' => 'authors',
'value' => '"' . $auteur . '"',
'compare' => 'LIKE',
),
array(
'key' => 'main_author',
'value' => $auteur,
'compare' => 'LIKE'
)
'compare' => 'LIKE',
),
);
}
@ -96,9 +101,9 @@ function build_posts($request)
ob_start();
if ($posts_query->have_posts()) :
while ($posts_query->have_posts()) : $posts_query->the_post();
get_template_part('template-parts/components/cards/post-card', null, array(
get_template_part('template-parts/components/cards/post-card', null, array(
'ID' => get_the_ID(),
));
));
endwhile;
else :
echo '<p>Aucun article trouvé.</p>';
@ -118,4 +123,3 @@ function build_posts($request)
return $response;
}

View File

@ -94,6 +94,7 @@ function handle_posts_numerotation_remapping($post_type)
function hasPostTypeNumerotation($post_type)
{
switch ($post_type) {
case 'articles':
case 'analyses-etudes':
case 'expositions':
case 'outils-pedagogiques':
@ -381,7 +382,7 @@ function get_authors_linked_to_posts(array $post_ids)
foreach ($post_ids as $post_id) {
$post_authors = get_field('authors', $post_id);
if (empty($post_authors)) continue;
foreach ($post_authors as $author) {
$author_id = is_object($author) ? $author->ID : (int) $author;
if ($author_id) {
@ -399,4 +400,22 @@ function get_authors_linked_to_posts(array $post_ids)
'orderby' => 'title',
'order' => 'ASC',
));
}
}
function get_current_post_numerotation($post_id)
{
$current_blog_id = get_current_blog_id();
if ($current_blog_id === 1) {
return get_post_meta($post_id, 'post_numerotation', true);
}
if ($current_blog_id === 2) {
$related_revue = get_field('related_revue', $post_id);
$related_revue_issue_number = $related_revue ? get_field('issue_number', $related_revue) : null;
return $related_revue_issue_number;
}
return null;
}

View File

@ -47,6 +47,7 @@
@import './components/post-tag.css';
@import './components/content-wrapper.css';
@import './components/content-area.css';
@import './components/authors-list.css';
/* ########### EDITOR CONTENT ############ */
@import './editor-content/entry-content.css';
@ -99,7 +100,8 @@
@import './blocks/highlight-timeline-step.css';
@import './blocks/highlight-timeline.css';
@import './blocks/press-ressources.css';
@import './blocks/document-card.css';
@import './blocks/wp-block-file.css';
@import './blocks/wp-block-heading.css';
@import './blocks/wp-block-list.css';
@import './blocks/wp-block-list-is-iconed-list.css';
@ -107,6 +109,7 @@
@import './blocks/wp-block-details.css';
@import './blocks/wp-block-image.css';
@import './blocks/wp-block-buttons.css';
@import './blocks/explore-tags.css';
@import './blocks/variants.css';

View File

@ -60,10 +60,10 @@ h2.chapter-section__title {
font-family: 'Nunito Sans', sans-serif !important;
}
.subtitle-big {
@apply text-4xl md:text-5xl font-normal uppercase fjalla pb-6;
@apply text-4xl md:!text-5xl font-normal uppercase fjalla pb-6;
line-height: 1.2;
@screen lg {
line-height: 1.3;
line-height: 1.3 !important;
}
/* text-rendering: geometricPrecision; */
font-weight: 400 !important;

View File

@ -10,15 +10,17 @@
&--variant-backgrounded {
background-color: var(--content-box-background-color, transparent);
}
&--variant-framed-backgrounded {
@apply border border-carhop-green-600;
background-color: var(--content-box-background-color, transparent);
}
&.alignwide, &.aligncontained {
&.alignwide,
&.aligncontained {
@apply !mx-auto;
}
&.aligncontained {
@apply !max-w-screen-lg ;
@apply !max-w-screen-lg;
}
/* &.alignwide {
@apply max-w-screen-lg;
@ -58,16 +60,15 @@
}
&__innerblocks {
@apply mx-auto px-4 md:px-8;
>:not(.alignwide):not(.alignfull) {
@apply max-w-screen-lg mx-auto ;
}
@apply mx-auto px-4 md:px-8;
> :not(.alignwide):not(.alignfull) {
@apply max-w-screen-lg mx-auto;
}
}
&.alignwide .content-box__innerblocks{
>:not(.alignfull) {
@apply max-w-screen-xl mx-auto ;
}
&.alignwide .content-box__innerblocks {
> :not(.alignfull) {
@apply max-w-screen-xl mx-auto;
}
}
h3 {
/* @apply title-small font-bold; */
@ -139,6 +140,7 @@ body.wp-admin.post-type-articles .content-box,
}
}
body.single-activites .content-box,
body.wp-admin.post-type-page .content-box,
body.page .content-box {
@apply py-16;

View File

@ -0,0 +1,47 @@
.wp-block-carhop-blocks-document-card {
@apply border border-solid border-primary p-8 bg-white grid items-center mb-6;
grid-template-columns: 1fr auto;
&:after {
@apply content-[''] block !w-20 !h-20 bg-center bg-no-repeat;
transition: transform 0.3s ease-in-out;
background-image: url('../resources/img/carhop-fleche-full-green_down.svg') !important;
transform: translateY(-5px);
}
&:hover:after {
transform: translateY(14px);
}
.file_info {
@apply flex items-center text-primary;
}
.wp-block-carhop-blocks-heading {
@apply !pb-4;
.carhop-heading__innerblocks {
@apply !gap-2;
}
h1,
h2,
h3,
h4,
h5,
h6 {
@apply nunito !normal-case !tracking-wide;
}
p {
@apply !text-3xl;
}
+ .file_info {
@apply !mt-4;
}
}
p {
@apply mb-4;
}
}

View File

@ -0,0 +1,54 @@
.explore-tags {
@apply bg-carhop-purple-100 py-24 px-4 md:px-12 xl:px-24;
&.alignfull {
@apply !my-0;
}
.inner {
@apply max-w-screen-2xl mx-auto;
@apply lg:flex gap-16 xl:gap-32;
}
&__subtitle {
br {
display: none;
}
@screen lg {
br {
display: block;
}
}
}
.tag-list {
@apply flex gap-6 flex-wrap;
&__tag {
@apply text-lg font-normal border border-primary p-4 h-fit flex items-center gap-2;
svg {
transition: transform 0.3s ease-in-out;
@apply w-8 h-8;
circle {
@apply fill-primary stroke-transparent;
}
path {
@apply stroke-white;
}
}
&:hover {
@apply bg-primary text-white;
svg {
transform: rotate(90deg);
circle {
@apply fill-white;
}
path {
@apply stroke-primary;
}
}
}
}
}
}
.is-website-carhop .explore-tags {
@apply bg-carhop-orange-50;
}

View File

@ -0,0 +1,38 @@
.wp-block-file {
@apply text-primary font-semibold !text-lg flex gap-2 items-center;
transition: all 0.3s ease;
a:not([download]) {
&:hover {
@apply underline underline-offset-8;
}
&:after {
content: none;
}
}
a[download] {
@apply bg-transparent !text-white !no-underline inline-flex items-center gap-12 relative w-10 h-10 ml-4;
color: transparent !important;
font-size: 0; /* Réduit l'espace occupé */
text-indent: -9999px;
transition: all 0.3s ease;
&:after {
@apply w-10 h-10 bg-transparent absolute top-0 left-0;
background-image: url('../resources/img/icons/button-arrow-down-small.svg');
background-size: contain;
background-repeat: no-repeat;
background-position: center;
content: ' ';
display: block;
transform: translateY(0);
}
}
&:hover {
a[download] {
transform: translateY(3px);
}
}
}

View File

@ -17,4 +17,6 @@
border-left: none !important;
border-right: none !important;
}
@apply mb-12;
}

View File

@ -51,6 +51,30 @@
@apply text-2xl uppercase font-medium tracking-normal;
}
.author-card__author-status {
@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-plume2.svg');
background-size: contain;
background-repeat: no-repeat !important;
background-position: center;
}
&--author:before {
background-image: url('../resources/img/icons/carhop-plume2.svg');
}
&--main-author:before {
@apply w-8 h-8;
transform: translateY(-5px);
background-image: url('../resources/img/icons/carhop-auteur-principal.svg');
}
&--publication-director:before {
@apply w-6 h-6;
background-image: url('../resources/img/icons/carhop-auteur-directeur.svg');
}
}
.author-card__articles-amount {
@apply text-primary font-normal flex items-center gap-2;

View File

@ -0,0 +1,12 @@
.authors-list {
@apply mb-20;
&__title {
@apply text-3xl font-medium mb-4 uppercase;
}
&__article-title {
@apply mb-8 underline underline-offset-8 decoration-1 opacity-90;
}
.author-card {
@apply mb-8;
}
}

View File

@ -9,6 +9,9 @@
@apply grid gap-6;
grid-template-columns: 1fr 3fr;
}
&.post-card--has-numerotation.post-card--has-thumbnail {
grid-template-columns: 1fr 3fr;
}
&__thumbnail {
@apply bg-white border border-solid border-primary p-2 h-fit grayscale hover:grayscale-0;
@ -25,7 +28,7 @@
}
h3.card__title {
@apply mb-6;
@apply mb-6 text-2xl uppercase;
}
.card__details {
@apply flex flex-col gap-3;
@ -52,22 +55,32 @@
&__authors {
/* @apply flex flex-wrap gap-2; */
@apply flex flex-wrap gap-x-8 gap-y-2;
@apply flex flex-wrap gap-x-6 gap-y-2;
li {
@apply text-lg flex items-center gap-2;
&::before {
@apply w-6 h-6 block bg-no-repeat bg-center bg-contain;
content: '';
@apply filter-primary;
/* @apply filter-primary; */
}
&.author::before {
background-image: url('../resources/img/icons/carhop-plume2.svg');
}
&.main-author::before {
width: 2.15rem;
height: 2.15rem;
transform: translateY(-5px);
background-image: url('../resources/img/icons/carhop-auteur-principal.svg');
}
&.editor::before {
background-image: url('../resources/img/icons/carhop-bookmark.svg');
}
&.publication-director::before {
@apply w-8 h-8;
background-image: url('../resources/img/icons/carhop-auteur-directeur.svg');
}
}
}
&__details-text {

View File

@ -6,19 +6,28 @@
@apply uppercase font-medium text-4xl md:text-5xl lg:text-5xl text-white;
line-height: 1.2;
}
&__main-author {
&__main-author,
&__first-author {
@apply text-white font-light tracking-wide flex items-center gap-3 mt-4;
&::before {
@apply w-6 h-6 block bg-no-repeat bg-center bg-contain;
content: '';
background-image: url('../resources/img/icons/carhop-plume2.svg');
filter: invert(1) brightness(0) saturate(100%) invert(100%);
}
&:hover {
@apply underline underline-offset-8;
}
}
&__first-author::before {
background-image: url('../resources/img/icons/carhop-plume2.svg');
}
&__main-author::before {
@apply w-8 h-8;
transform: translateY(-5px);
background-image: url('../resources/img/icons/carhop-auteur-principal.svg');
}
&__inner {
@apply mx-auto grid gap-24;
@screen xl {

View File

@ -43,3 +43,42 @@ body {
.block-editor-block-list__block.wp-block-carhop-blocks-heading {
@apply mx-auto;
}
.wp-block-file {
.wp-block-file__content-wrapper {
@apply flex gap-2 items-center;
}
[data-wp-block-attribute-key='fileName'] {
@apply underline-offset-8;
}
[data-wp-block-attribute-key='downloadButtonText'] {
@apply relative w-10 h-10 bg-transparent inline-flex items-center gap-12;
color: transparent !important;
font-size: 0; /* Réduit l'espace occupé */
text-indent: -9999px;
transition: all 0.3s ease;
&:after {
@apply w-10 h-10 bg-transparent absolute top-0 left-0;
background-image: url('../resources/img/icons/button-arrow-down-small.svg');
background-size: contain;
background-repeat: no-repeat;
background-position: center;
content: ' ';
display: block;
transform: translateY(0);
}
}
/* @apply text-primary font-semibold !text-lg flex gap-2 items-center;
transition: all 0.3s ease;
a:not([download]) {
&:hover {
@apply underline underline-offset-8;
}
} */
}
.wp-block-carhop-blocks-document-card:focus:after {
@apply !static;
}

View File

@ -98,3 +98,11 @@ details {
@apply text-primary;
}
}
h3.wp-block-heading:has(+ .wp-block-table) {
@apply nunito text-base tracking-widest;
}
/* .wp-block-table + h3.wp-block-heading {
@apply mt-16;
} */

View File

@ -60,4 +60,10 @@
@apply flex gap-4;
}
}
.content-area .alignfull {
@media (min-width: 1024px) {
margin: 0 calc(-50vw + 50% + 24.26%) !important;
}
}
}

View File

@ -22,5 +22,11 @@
@apply hidden;
}
}
&[data-active-tab='informations'] {
#post-authors,
.post-content {
@apply hidden;
}
}
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="fleche-full" xmlns="http://www.w3.org/2000/svg" width="77" height="77" viewBox="0 0 77 77">
<path d="M39.5,50.8v-23.1" style="fill: none; stroke: #146f63; stroke-width: 2px;"/>
<path d="M25.4,36.1l14.2,14.7,14.2-14.7" style="fill: none; stroke: #146f63; stroke-width: 2px;"/>
<circle cx="38.5" cy="38.5" r="37.5" style="fill: none; stroke: #146f63; stroke-width: 2px;"/>
</svg>

After

Width:  |  Height:  |  Size: 431 B

View File

@ -0,0 +1,14 @@
<svg width="26" height="27" viewBox="0 0 26 27" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_3654_30453)">
<path d="M19.5281 6.71179H0.765625V10.1059V26.2339H19.5281V6.71179Z" stroke="#136F63" stroke-width="2"/>
<path d="M19.5258 21.5909H25.2348V0.766235H5.22656V6.71175" stroke="#136F63" stroke-width="2"/>
<path d="M16.463 11.8988L15.1714 12.7799V17.4995L7.07031 22.0046L8.0562 13.2012L12.3131 10.9487L12.3819 9.30908" stroke="#136F63" stroke-width="2"/>
<path d="M7.07031 22.0046L10.4254 16.9631" stroke="#136F63" stroke-width="2"/>
<path d="M3.21875 22.8245H7.0706" stroke="#136F63" stroke-width="2"/>
</g>
<defs>
<clipPath id="clip0_3654_30453">
<rect width="26" height="27" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 750 B

View File

@ -0,0 +1,13 @@
<svg width="29" height="28" viewBox="0 0 29 28" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_3654_19489)">
<path d="M17.466 13.1028L15.7614 14.2747V20.5661L5.08594 26.5718L6.37884 14.8313L11.991 11.8285L12.0849 9.64587" stroke="#136F63" stroke-width="2"/>
<path d="M5.08594 26.5719L9.50636 19.8557" stroke="#136F63" stroke-width="2"/>
<path d="M0 27.2676H5.08493" stroke="#136F63" stroke-width="2"/>
<path d="M22.6816 1.03366L17.375 6.41455L22.6816 11.7954L27.9881 6.41455L22.6816 1.03366Z" stroke="#136F63" stroke-width="2"/>
</g>
<defs>
<clipPath id="clip0_3654_19489">
<rect width="29" height="28" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 671 B

View File

@ -1,140 +1,159 @@
//post-grid__toolbar-actions
export default function archivesInit() {
const isArchivePage = document.querySelector('body.archive');
if (!isArchivePage) return;
const isArchivePage = document.querySelector('body.archive');
if (!isArchivePage) return;
const toolbar = document.querySelector('.post-grid__toolbar');
if (!toolbar) return;
const toolbar = document.querySelector('.post-grid__toolbar');
if (!toolbar) return;
const postGridToolbarActions = toolbar.querySelector('.post-grid__toolbar-actions');
const currentPostType = postGridToolbarActions?.getAttribute('data-post-type') as string;
const etiquettesSelect = toolbar.querySelector('select[name="etiquettes"]') as HTMLSelectElement;
const auteursSelect = toolbar.querySelector('select[name="auteurs"]') as HTMLSelectElement;
const sortBySelect = toolbar.querySelector('select[name="sort_by"]') as HTMLSelectElement;
const rechercheInput = toolbar.querySelector('.search-bar input') as HTMLInputElement;
console.log('currentPostType', currentPostType);
console.log('etiquettesSelect', etiquettesSelect);
console.log('auteursSelect', auteursSelect);
console.log('sortBySelect', sortBySelect);
console.log('rechercheInput', rechercheInput);
const postGridToolbarActions = toolbar.querySelector('.post-grid__toolbar-actions');
const currentPostType = postGridToolbarActions?.getAttribute(
'data-post-type',
) as string;
const etiquettesSelect = toolbar.querySelector(
'select[name="etiquettes"]',
) as HTMLSelectElement;
const auteursSelect = toolbar.querySelector(
'select[name="auteurs"]',
) as HTMLSelectElement;
const sortBySelect = toolbar.querySelector(
'select[name="sort_by"]',
) as HTMLSelectElement;
const rechercheInput = toolbar.querySelector('.search-bar input') as HTMLInputElement;
// Évite les courses: annule les requêtes précédentes et ignore les réponses obsolètes
let currentAbortController: AbortController | null = null;
let lastRequestId = 0;
// Debounce simple pour la recherche
function debounce<T extends (...args: any[]) => void>(fn: T, waitMs: number) {
let timeoutId: number | undefined;
return (...args: Parameters<T>) => {
if (timeoutId) window.clearTimeout(timeoutId);
timeoutId = window.setTimeout(() => fn(...args), waitMs);
};
}
// Debounce simple pour la recherche
function debounce<T extends (...args: any[]) => void>(fn: T, waitMs: number) {
let timeoutId: number | undefined;
return (...args: Parameters<T>) => {
if (timeoutId) window.clearTimeout(timeoutId);
timeoutId = window.setTimeout(() => fn(...args), waitMs);
};
}
async function hydratePosts() {
const etiquetteValue = etiquettesSelect?.value ?? '';
const auteurValue = auteursSelect?.value ?? '';
const sortByValue = sortBySelect?.value ?? '';
const rechercheValue = rechercheInput?.value ?? '';
const postTypeValue = currentPostType ?? '';
async function hydratePosts() {
const etiquetteValue = etiquettesSelect?.value ?? '';
const auteurValue = auteursSelect?.value ?? '';
const sortByValue = sortBySelect?.value ?? '';
const rechercheValue = rechercheInput?.value ?? '';
const postTypeValue = currentPostType ?? '';
const params = new URLSearchParams({
etiquette: etiquetteValue,
auteur: auteurValue,
sort_by: sortByValue,
recherche: rechercheValue,
post_type: postTypeValue,
});
console.log(params.toString());
const url = `/wp-json/carhop-datas/v1/build/posts?${params.toString()}`;
// Annule la précédente et prépare un nouvel identifiant
if (currentAbortController) currentAbortController.abort();
currentAbortController = new AbortController();
const requestId = ++lastRequestId;
try {
const response = await fetch(url, { signal: currentAbortController.signal });
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
console.log('data', data);
// Ignore si une requête plus récente a été envoyée
if (requestId !== lastRequestId) return;
const articlesContainer = document.querySelector('.post-grid__list');
if (!articlesContainer) return;
articlesContainer.innerHTML = data.html_template;
updatePostCount(data.post_count);
} catch (error) {
if ((error as any)?.name === 'AbortError') return;
console.error('Erreur lors de la récupération des articles:', error);
}
}
const hydratePostsDebounced = debounce(hydratePosts, 150);
function resetCurrentFilters() {
if (!etiquettesSelect || !auteursSelect || !rechercheInput) return;
etiquettesSelect.value = '';
auteursSelect.value = '';
rechercheInput.value = '';
}
function setFilterByActivebutton(button: HTMLButtonElement) {
const filterByButtons = document.querySelectorAll('.search-by button');
if (!filterByButtons) return;
filterByButtons.forEach((button) => {
button.setAttribute('aria-selected', 'false');
});
button.setAttribute('aria-selected', 'true');
}
function handleFilterPostsBy() {
const filterByButtons = document.querySelectorAll('.search-by button');
if (!filterByButtons) return;
filterByButtons.forEach((button) => {
button.addEventListener('click', (e) => {
e.preventDefault();
setFilterByActivebutton(button as HTMLButtonElement);
resetCurrentFilters();
hydratePosts(); // immédiat sur action explicite
});
});
}
auteursSelect.addEventListener('change', (e) => {
hydratePosts();
const params = new URLSearchParams({
etiquette: etiquetteValue,
auteur: auteurValue,
sort_by: sortByValue,
recherche: rechercheValue,
post_type: postTypeValue,
});
etiquettesSelect.addEventListener('change', (e) => {
hydratePosts();
});
const url = `/wp-json/carhop-datas/v1/build/posts?${params.toString()}`;
sortBySelect.addEventListener('change', (e) => {
hydratePosts(); // immédiat pour le tri
});
rechercheInput.addEventListener('input', (e) => {
hydratePostsDebounced(); // debounce pour la saisie rapide
});
handleFilterPostsBy();
// Annule la précédente et prépare un nouvel identifiant
if (currentAbortController) currentAbortController.abort();
currentAbortController = new AbortController();
const requestId = ++lastRequestId;
try {
const response = await fetch(url, { signal: currentAbortController.signal });
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
postGridToolbarActions.addEventListener('click', (e) => {
console.log('data', data);
// Ignore si une requête plus récente a été envoyée
if (requestId !== lastRequestId) return;
const articlesContainer = document.querySelector('.post-grid__list');
if (!articlesContainer) return;
articlesContainer.innerHTML = data.html_template;
updatePostCount(data.post_count);
} catch (error) {
if ((error as any)?.name === 'AbortError') return;
console.error('Erreur lors de la récupération des articles:', error);
}
}
const hydratePostsDebounced = debounce(hydratePosts, 150);
function resetCurrentFilters() {
if (!etiquettesSelect || !auteursSelect || !rechercheInput) return;
etiquettesSelect.value = '';
auteursSelect.value = '';
rechercheInput.value = '';
}
function setFilterByActivebutton(button: HTMLButtonElement) {
const filterByButtons = document.querySelectorAll('.search-by button');
if (!filterByButtons) return;
filterByButtons.forEach((button) => {
button.setAttribute('aria-selected', 'false');
});
button.setAttribute('aria-selected', 'true');
}
function handleFilterPostsBy() {
const filterByButtons = document.querySelectorAll('.search-by button');
if (!filterByButtons) return;
filterByButtons.forEach((button) => {
button.addEventListener('click', (e) => {
e.preventDefault();
setFilterByActivebutton(button as HTMLButtonElement);
resetCurrentFilters();
hydratePosts(); // immédiat sur action explicite
});
});
}
}
auteursSelect.addEventListener('change', (e) => {
hydratePosts();
});
etiquettesSelect.addEventListener('change', (e) => {
hydratePosts();
});
sortBySelect.addEventListener('change', (e) => {
hydratePosts(); // immédiat pour le tri
});
rechercheInput.addEventListener('input', (e) => {
hydratePostsDebounced(); // debounce pour la saisie rapide
});
handleFilterPostsBy();
postGridToolbarActions.addEventListener('click', (e) => {
e.preventDefault();
});
}
function updatePostCount(count: number) {
const postCount = document.querySelector('.post-count__count');
if (!postCount) return;
postCount.innerHTML = count.toString();
}
function scrollToPostsGridIfHasInitialFilter() {
const postsGrid = document.querySelector('.post-grid');
const hasInitialFilter = postsGrid?.classList.contains('has-initial-filter');
if (!hasInitialFilter || !postsGrid) return;
setTimeout(() => {
postsGrid.scrollIntoView({ behavior: 'smooth' });
}, 200);
setTimeout(() => {
const etiquettesSelect = document.querySelector(
'.post-grid__toolbar-actions select[name="etiquettes"]',
) as HTMLSelectElement;
if (!etiquettesSelect) return;
etiquettesSelect.focus();
}, 500);
}
window.addEventListener('load', () => {
scrollToPostsGridIfHasInitialFilter();
});

View File

@ -30,14 +30,9 @@ $postType = get_post_type();
)); ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php echo do_blocks('<!-- wp:carhop-blocks/explore-tags /-->'); ?>
</div>
<?php

View File

@ -2,19 +2,54 @@
$postId = $args['postId'];
$componentTitle = 'Auteur·e·s de l\'article';
$authors = get_field('authors', $postId);
$has_main_author = get_field('has_main_author', $postId);
$main_author = get_field('main_author', $postId);
$show_author_status = $has_main_author && $main_author ? true : false;
$has_publication_direction = get_field('has_publication_direction', $postId);
$publication_directors = get_field('publication_directors', $postId);
?>
<section class="authors-list">
<h3 class="authors-list__title"><?php echo $componentTitle; ?></h3>
<?php foreach ($authors as $author) : ?>
<?php if ($has_main_author && $main_author) : ?>
<?php get_template_part(
'template-parts/components/cards/author-card',
null,
array(
'ID' => $main_author->ID,
'show_author_status' => $show_author_status,
'author_status' => 'main-author',
)
); ?>
<?php endif; ?>
<?php foreach ($authors as $author) : ?>
<?php get_template_part(
'template-parts/components/cards/author-card',
null,
array(
'ID' => $author->ID,
'show_author_status' => $show_author_status,
'author_status' => 'author',
)
); ?>
<?php endforeach; ?>
<?php if ($has_publication_direction && $publication_directors) : ?>
<h3 class="authors-list__title"><?php echo "Sous la direction de"; ?></h3>
<?php foreach ($publication_directors as $publication_director) : ?>
<?php get_template_part(
'template-parts/components/cards/author-card',
null,
array(
'ID' => $publication_director->ID,
'show_author_status' => $show_author_status,
'author_status' => 'publication-director',
)
); ?>
<?php endforeach; ?>
<?php endif; ?>
</section>

View File

@ -4,22 +4,23 @@ $posts_query = $args['posts_query'] ?? null;
$post_count = $posts_query->post_count;
$current_post_type_obj = get_post_type_object($current_post_type);
$etiquette_active_filter_slug = $args['etiquette_active_filter_slug'] ?? null;
$post_ids = wp_list_pluck($posts_query->posts, 'ID');
$types = get_terms(array(
'taxonomy' => 'type',
'hide_empty' => true,
'taxonomy' => 'type',
'hide_empty' => true,
));
$authors = get_authors_linked_to_posts($post_ids);
$tags = get_terms(array(
'taxonomy' => 'etiquettes',
'hide_empty' => true,
'object_ids' => $post_ids,
'taxonomy' => 'etiquettes',
'hide_empty' => true,
'object_ids' => $post_ids,
));
?>
?>
<div class="post-grid__toolbar">
<div class="search-by">
@ -39,7 +40,7 @@ $tags = get_terms(array(
<select name="etiquettes">
<option value=""><?php _e('Tous les tags', 'dynamiques'); ?></option>
<?php foreach ($tags as $tag) : ?>
<option value="<?php echo $tag->slug; ?>"><?php echo $tag->name; ?></option>
<option value="<?php echo $tag->slug; ?>" <?php selected($etiquette_active_filter_slug, $tag->slug); ?>><?php echo $tag->name; ?></option>
<?php endforeach; ?>
</select>
@ -71,4 +72,4 @@ $tags = get_terms(array(
<option value="date_asc"><?php _e('Numéros anciens en premier', 'dynamiques'); ?></option>
<option value="title_asc"><?php _e('Par ordre alphabétique', 'dynamiques'); ?></option>
</select>
</div>
</div>

View File

@ -3,21 +3,43 @@ $post_amount = $args['post_amount'] ?? -1;
$grid_title = $args['grid_title'] ?? 'Trouver une publication';
$current_post_type = $args['current_post_type'] ?? get_post_type();
$posts_query = new WP_Query(array(
// Récupérer le paramètre etiquette de l'URL
$etiquette_slug = isset($_GET['etiquette']) ? sanitize_text_field($_GET['etiquette']) : '';
// Construire les arguments de la query
$query_args = array(
'post_type' => $current_post_type,
'posts_per_page' => $post_amount
));
'posts_per_page' => $post_amount,
'post_status' => 'publish',
);
// Si on a une étiquette, ajouter le filtre taxonomy
if (!empty($etiquette_slug)) {
$query_args['tax_query'] = array(
array(
'taxonomy' => 'etiquettes',
'field' => 'slug',
'terms' => $etiquette_slug,
),
);
}
$posts_query = new WP_Query($query_args);
?>
<section class="post-grid content-section">
<section class="post-grid content-section <?php echo !empty($etiquette_slug) ? 'has-initial-filter' : '' ?>">
<h2 class="find-publication__title title-small"><?php echo $grid_title; ?></h2>
<div class="content-section__inner">
<?php get_template_part('template-parts/components/archive/post-grid-toolbar', null, array(
'posts_query' => $posts_query,
'current_post_type' => $current_post_type,
)); ?>
<?php get_template_part('template-parts/components/archive/post-grid-toolbar', null, array(
'posts_query' => $posts_query,
'current_post_type' => $current_post_type,
'etiquette_active_filter_slug' => $etiquette_slug,
)); ?>
<ul class="post-grid__list">
<?php if (isset($posts_query) && $posts_query->have_posts()) : ?>

View File

@ -1,5 +1,6 @@
<?php
$ID = $args['ID'];
$ID = $args['ID'] ?? get_the_ID();
$name = get_the_title($ID);
$link = get_the_permalink($ID);
$profilePicture = get_field('profile_thumbnail', $ID);
@ -7,6 +8,23 @@ $profilePictureUrl = $profilePicture['url'] ?? '';
$profilePictureAlt = $profilePicture['alt'] ?? '';
$description = get_field('description', $ID);
$show_author_status = $args['show_author_status'] ?? false;
$author_status = $args['author_status'] ?? 'author';
$author_status_label = '';
switch ($author_status) {
case 'main-author':
$author_status_label = 'Auteur·e principal';
break;
case 'publication-director':
$author_status_label = 'Directeur·e de publication';
break;
default:
case 'author':
$author_status_label = 'Auteur·e';
break;
}
$is_carhop_member = get_field('is_carhop_member', $ID);
$carhop_member_id = get_field('carhop_member', $ID);
@ -32,6 +50,11 @@ if ($is_carhop_member && isset($carhop_member_id)) {
</div>
<div class="author-card__infos">
<h3 class="author-card__name"><?php echo $name; ?></h3>
<?php if ($show_author_status) : ?>
<div class="author-card__author-status author-card__author-status--<?php echo $author_status; ?>">
<?php echo $author_status_label; ?>
</div>
<?php endif; ?>
</div>

View File

@ -4,6 +4,8 @@ $current_post_type = $args['current_post_type'] ?? get_post_type();
$title = get_the_title($ID);
$showExcerpt = $args['show_excerpt'] ?? false;
$showTags = $args['showTags'] ?? true;
$excerpt = get_the_excerpt($ID);
$link = get_the_permalink($ID);
@ -13,8 +15,14 @@ $thumbnail_url = get_the_post_thumbnail_url($ID) ?? null;
$date = get_the_date('F Y', $ID);
$authors = get_field('authors', $ID);
$has_main_author = get_field('has_main_author', $ID);
$main_author = get_field('main_author', $ID);
$editors = get_field('editors', $ID);
$has_publication_direction = get_field('has_publication_direction', $ID);
$publication_directors = get_field('publication_directors', $ID);
$numerotation = get_post_meta($ID, 'post_numerotation', true);
$tags = get_the_terms($ID, 'etiquettes');
@ -44,12 +52,21 @@ $tags = get_the_terms($ID, 'etiquettes');
<?php if ($authors) : ?>
<ul class="post-card__authors">
<?php if ($has_main_author && $main_author) : ?>
<li class="main-author"><?php echo $main_author->post_title; ?></li>
<?php endif; ?>
<?php foreach ($authors as $author) : ?>
<li class="author"><?php echo $author->post_title; ?></li>
<?php endforeach; ?>
<?php foreach ($editors as $editor) : ?>
<li class="editor"><?php echo $editor->post_title; ?></li>
<?php endforeach; ?>
<?php if ($has_publication_direction && $publication_directors) : ?>
<?php foreach ($publication_directors as $publication_director) : ?>
<li class="publication-director">Sous la direction de <?php echo $publication_director->post_title; ?></li>
<?php endforeach; ?>
<?php endif; ?>
<?php if ($editors) : ?>
<li class="editor"><?php echo $editors; ?></li>
<?php endif; ?>
</ul>
<?php endif; ?>
</div>
@ -58,7 +75,7 @@ $tags = get_the_terms($ID, 'etiquettes');
<?php the_post_thumbnail('medium'); ?>
</div>
<?php endif; ?>
<?php if ($tags) : ?>
<?php if ($showTags && $tags) : ?>
<ul class="tag-list">
<?php foreach ($tags as $tag) : ?>
<li class="tag-list__tag"><?php echo $tag->name; ?></li>

View File

@ -27,7 +27,11 @@ if ($current_post_type_supports_type) {
<?php if ($hasNumerotation) : ?>
<?php
$numerotation = get_post_meta($current_post_id, 'post_numerotation', true); ?>
$numerotation = get_current_post_numerotation($current_post_id);
?>
<p class="content-meta__revue-issue content-meta__revue-issue--green">
<span class="revue-issue-number revue-meta__label sr-only">Numéro</span>
<?php echo $numerotation; ?>

View File

@ -13,7 +13,6 @@
// get_template_part('template-parts/authors/authors-last-publications', null, array(
// 'postId' => get_the_ID()
// ));
?>
</div>

View File

@ -5,7 +5,12 @@ $post_id = get_the_ID();
$postTitle = get_the_title($post_id);
$hasNumerotation = hasPostTypeNumerotation($post_id);
$hasThumbnail = has_post_thumbnail();
$authors = get_field('authors', $ID);
$has_main_author = get_field('has_main_author', $ID);
$main_author = get_field('main_author', $ID);
$post_date_info_label = $args['post_date_info_label'] ?? 'Parution';
$thumbnail_position = $args['thumbnail_position'] ?? 'left';
$has_thumbnail_overlay = $args['has_thumbnail_overlay'] ?? false;
@ -45,8 +50,13 @@ $has_thumbnail_overlay = $args['has_thumbnail_overlay'] ?? false;
)); ?>
<h1 class="post-header__title"> <?php echo $postTitle; ?></h1>
<?php if ($authors && is_array($authors) && count($authors) > 0) : ?>
<a class="post-header__main-author" href="<?php echo get_the_permalink($authors[0]->ID); ?>">
<?php if ($has_main_author && $main_author) : ?>
<a class="post-header__main-author" href="<?php echo get_the_permalink($main_author->ID); ?>">
<?php echo $main_author->post_title; ?>
</a>
<?php elseif ($authors && is_array($authors) && count($authors) > 0) : ?>
<a class="post-header__first-author" href="<?php echo get_the_permalink($authors[0]->ID); ?>">
<?php echo $authors[0]->post_title; ?>
</a>
<?php endif; ?>