Compare commits

..

No commits in common. "0ebaf0d0bf6064611c77992e2aa22f2f0fb3de13" and "0eb39603a95ec4a4520981b8ac1440b1a64cad53" have entirely different histories.

3 changed files with 76 additions and 62 deletions

View File

@ -331,6 +331,17 @@ function generate_og_meta_tags()
} elseif (is_single() || is_page()) {
$og_title = get_the_title();
$og_description = get_the_excerpt();
// Pour les articles, améliorer la description avec les métadonnées
if (empty($og_description) && get_post_type() === 'articles') {
// Essayer d'utiliser le champ de référence de citation si disponible
$cite_reference = get_field('cite_reference');
if (!empty($cite_reference)) {
$og_description = strip_tags($cite_reference);
}
}
// Fallback vers le contenu si toujours vide
if (empty($og_description)) {
$og_description = wp_trim_words(strip_tags(get_the_content()), 30);
}
@ -353,8 +364,29 @@ function generate_og_meta_tags()
$og_description = str_replace(array("\r", "\n", "\t"), ' ', $og_description);
$og_description = wp_trim_words($og_description, 30);
// Image Open Graph fixe
$og_image = get_template_directory_uri() . '/resources/img/og/dynamiques-og.png';
// Image
$og_image = '';
if (is_single() || is_page()) {
if (has_post_thumbnail()) {
$og_image = get_the_post_thumbnail_url(null, 'large');
}
}
// Image par défaut si aucune image n'est trouvée
if (empty($og_image)) {
// Essayer d'utiliser le logo personnalisé du site
$custom_logo = wp_get_attachment_image_src(get_theme_mod('custom_logo'), 'large');
if ($custom_logo) {
$og_image = $custom_logo[0];
} else {
// Utiliser l'icône du site
$og_image = get_site_icon_url(512);
// Si pas d'icône de site, utiliser une image par défaut du thème
if (empty($og_image)) {
$og_image = get_template_directory_uri() . '/resources/img/covers/carhop-articles-page-cover.svg';
}
}
}
// Type de contenu
$og_type = is_single() ? 'article' : 'website';
@ -364,8 +396,30 @@ function generate_og_meta_tags()
// Auteur (pour les articles)
$og_author = '';
$article_authors = array();
if (is_single()) {
$og_author = get_the_author_meta('display_name');
$post_type = get_post_type();
if ($post_type === 'articles') {
// Pour les articles, utiliser le champ ACF 'authors'
$authors = get_field('authors');
if ($authors && is_array($authors)) {
foreach ($authors as $author) {
$first_name = get_field('first_name', $author->ID) ?: '';
$last_name = get_field('last_name', $author->ID) ?: '';
$author_name = trim($first_name . ' ' . $last_name);
if (empty($author_name)) {
$author_name = $author->post_title;
}
$article_authors[] = $author_name;
}
$og_author = implode(', ', $article_authors);
}
}
// Fallback vers l'auteur WordPress standard
if (empty($og_author)) {
$og_author = get_the_author_meta('display_name');
}
}
// Date de publication (pour les articles)
@ -403,6 +457,22 @@ function generate_og_meta_tags()
$meta_tags[] = '<meta property="article:modified_time" content="' . esc_attr($modified_time) . '" />';
}
// Ajouter les tags/sections pour les articles
if (is_single() && get_post_type() === 'articles') {
$article_tags = get_the_tags();
if ($article_tags) {
foreach ($article_tags as $tag) {
$meta_tags[] = '<meta property="article:tag" content="' . esc_attr($tag->name) . '" />';
}
}
// Ajouter la section/revue si disponible
$related_revue = get_field('related_revue');
if ($related_revue) {
$meta_tags[] = '<meta property="article:section" content="' . esc_attr($related_revue->post_title) . '" />';
}
}
// Twitter Cards
$meta_tags[] = '<meta name="twitter:card" content="summary_large_image" />';
$meta_tags[] = '<meta name="twitter:title" content="' . esc_attr($og_title) . '" />';

View File

@ -65,7 +65,7 @@
}
.post-details {
@apply flex flex-wrap justify-between gap-28 gap-y-8 mt-12;
@apply flex flex-wrap justify-between gap-28 mt-12;
grid-template-columns: 1fr 1fr;
&__label {
@ -75,8 +75,8 @@
}
.socials-buttons {
@apply flex flex-wrap justify-end gap-4 h-fit;
min-width: 470px;
@apply flex flex-wrap gap-4 h-fit;
&__button {
@apply bg-white text-carhop-green-700 px-4 lg:px-6 md:px-8 !py-3 lg:!py-4 font-normal rounded-full w-max flex items-center gap-2;
transition: transform 0.3s ease-in-out;
@ -90,62 +90,6 @@
img {
@apply w-7 h-7 filter-primary;
}
&--like {
transition: all 0.3s ease-in-out;
.button-action-text {
max-width: 0;
overflow: hidden;
white-space: nowrap;
}
.likes-count {
max-width: 200px;
overflow: hidden;
/* transition: max-width 0.3s ease-in-out; */
white-space: nowrap;
}
&[data-likes-count='0'] {
.button-action-text {
max-width: 200px;
}
.likes-count {
max-width: 0;
}
}
&:hover {
.button-action-text {
max-width: 200px;
transition: max-width 0.3s ease-in-out;
}
.likes-count {
max-width: 0;
}
}
&.is-disabled {
@apply opacity-100 cursor-not-allowed hover:opacity-80;
.likes-count {
@apply block;
}
.button-action-text {
@apply max-w-0;
}
}
&.is-disabled:hover {
.button-action-text {
@apply max-w-[200px];
}
.likes-count {
@apply max-w-0;
}
}
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB