MAJ 18022024

This commit is contained in:
sebvtl728
2025-02-18 18:35:24 +01:00
parent 26ecadd238
commit 94c215a253
7 changed files with 429 additions and 354 deletions
+1 -1
View File
@@ -153,7 +153,7 @@ const Home = () => {
Un service exceptionnel, une équipe formidable
</Typography>
<Typography variant="body2" sx={{ mt: 2, textAlign: "right", fontWeight: "bold" }}>
- Client 1
- zertides
</Typography>
</CardContent>
</Card>
+70 -28
View File
@@ -1,64 +1,93 @@
import React, { useState, useEffect } from "react";
import { Helmet } from "react-helmet-async"; // ✅ SEO
import ServicePageTemplate from "../ServicePageTemplate";
import { getPageById } from "../../wordpress";
/**
* ✅ Fonction pour supprimer les balises HTML des champs WYSIWYG
*/
const stripHtml = (html) => {
const doc = new DOMParser().parseFromString(html || "", "text/html");
return doc.body.textContent || "";
};
const ServiceQuatre = () => {
const [acfData, setAcfData] = useState(null);
const [seoData, setSeoData] = useState(null); // ✅ Stocke les données SEO de RankMath
const [loading, setLoading] = useState(true);
const pageId = 590; // 🔥 Remplace par l'ID réel de la page WordPress
const pageId = 590; // 🔥 ID réel de la page WordPress
useEffect(() => {
const fetchACFData = async () => {
const fetchPageData = async () => {
try {
const pageData = await getPageById(pageId);
setAcfData(pageData.acf);
// ✅ Vérification des données ACF
if (pageData.acf) {
setAcfData(pageData.acf);
} else {
console.warn("⚠ Aucune donnée ACF trouvée !");
}
// ✅ Récupération des données SEO depuis RankMath
if (pageData.rankMath?.assessor?.serpData) {
const serpData = pageData.rankMath.assessor.serpData;
console.log("📢 Données SEO récupérées :", serpData);
setSeoData({
metaTitle: serpData.title || pageData.title?.rendered || "Titre par défaut",
metaDescription: serpData.description || "Description par défaut",
keywords: serpData.focusKeywords || "bureau d'études, construction, rénovation",
ogImage: serpData.ogImage || "https://picsum.photos/id/1018/1920/1080.webp",
});
} else {
console.warn("⚠ Aucune donnée SEO trouvée dans RankMath !");
}
} catch (error) {
console.error("❌ Erreur récupération des champs ACF :", error);
console.error("❌ Erreur récupération des champs ACF et SEO :", error);
} finally {
setLoading(false);
}
};
fetchACFData();
fetchPageData();
}, []);
// ✅ Affichage du chargement en attendant les données ACF
if (loading) {
return <p>Chargement...</p>;
}
const serviceDetails = {
// Hero
title: acfData?.titre_principal || "Titre héros !", // ✅ Modifiable individuellement
subtitle: <span dangerouslySetInnerHTML={{ __html: acfData?.description_principal || "Description, héros" }} />,
title: acfData?.titre_principal || "Titre héros !",
subtitle: stripHtml(acfData?.description_principal) || "Description, héros",
image: "https://picsum.photos/id/1021/1920/1080.webp",
image: acfData?.hero_image || "https://preprod.octopusdesign.fr/api-octopus/server/wp-content/uploads/2025/02/service-securite-incendie.webp",
ctaText: "En savoir plus",
ctaLink: "/contact",
// section 1
interestTitle: acfData?.second_titre || "Titre interet", // ✅ Modifiable individuellement
description: <span dangerouslySetInnerHTML={{ __html: acfData?.second_description || "Description interet" }} />,
// section 2
desirTitle: "Titre", // ✅ Modifiable individuellement
interestTitle: acfData?.second_titre || "Titre interet",
description: stripHtml(acfData?.second_description) || "Description interet",
desirTitle: "Titre",
features: [
{
title: acfData?.titre_carte_one || "Titre !",
description: acfData?.description_carte_one || "Description.",
modalText: acfData?.description_carte_one || "Description Modal.",
description: stripHtml(acfData?.description_carte_one).substring(0, 100) + "...",
modalText: stripHtml(acfData?.description_carte_one) || "Description Modal.",
modalImage: "https://picsum.photos/id/300/800/400.webp",
},
{
title: acfData?.titre_carte_two || "Titre !",
description: acfData?.description_carte_two || "Description.",
modalText: acfData?.description_carte_two || "Description Modal.",
description: stripHtml(acfData?.description_carte_two).substring(0, 100) + "...",
modalText: stripHtml(acfData?.description_carte_two) || "Description Modal.",
modalImage: "https://picsum.photos/id/301/800/400.webp",
},
{
title: acfData?.titre_carte_tree || "Titre !",
description: acfData?.description_carte_tree || "Description.",
modalText: acfData?.description_carte_tree || "Description Modal.",
description: stripHtml(acfData?.description_carte_tree).substring(0, 100) + "...",
modalText: stripHtml(acfData?.description_carte_tree) || "Description Modal.",
modalImage: "https://picsum.photos/id/302/800/400.webp",
},
],
@@ -66,18 +95,31 @@ const ServiceQuatre = () => {
carouselItems: [
{
title: "Portfolio Modern",
description: "Montrez vos compétences avec un portfolio unique.",
image: "https://picsum.photos/id/305/800/400.webp",
description: "Description de l'image",
image: "https://preprod.octopusdesign.fr/api-octopus/server/wp-content/uploads/2025/02/securite-incendie.webp",
width: 800,
height: 400,
},
{
title: "Blog SEO",
description: "Optimisez vos articles pour le référencement.",
image: "https://picsum.photos/id/306/800/400.webp",
title: "service securité S.S.I",
description: "Description de l'image",
image: "https://preprod.octopusdesign.fr/api-octopus/server/wp-content/uploads/2025/02/service-securite-ssi.webp",
width: 800,
height: 400,
},
],
// ✅ Ajout du SEO dynamique récupéré via RankMath
seo: {
metaTitle: seoData?.metaTitle || "Pourquoi faire appel à un bureau d’études ?",
metaDescription: seoData?.metaDescription || "Description SEO par défaut",
keywords: seoData?.keywords || "bureau d'études, construction, rénovation",
ogImage: seoData?.ogImage || "https://preprod.octopusdesign.fr/api-octopus/server/wp-content/uploads/2025/02/service-securite-incendie.webp",
},
};
return <ServicePageTemplate {...serviceDetails} />;
return <ServicePageTemplate {...serviceDetails} />
};
export default ServiceQuatre;
export default ServiceQuatre;