bug affichage post

This commit is contained in:
sebvtl728 2025-07-31 20:15:17 +02:00
parent 51195ac398
commit 7c01c6e81d

View File

@ -43,19 +43,27 @@ const Posts = () => {
return html.replace(/(<([^>]+)>)/gi, ""); // Supprime toutes les balises HTML
};
const decodeHtml = (html) => {
const txt = document.createElement("textarea");
txt.innerHTML = html;
return txt.value;
};
// Fonction pour tronquer un texte à 100 caractères max
const truncateText = (text, maxLength) => {
const strippedText = stripHtmlTags(text
.replace(/<[^>]*>/g, "") // Supprime les balises HTML
.replace(/&nbsp;/g, " ") // Remplace les espaces non bris
); // Nettoyage HTML
return strippedText.length > maxLength ? `${strippedText.substring(0, maxLength)}...` : strippedText;
};
const truncateText = (text, maxLength) => {
const parser = new DOMParser();
const decoded = parser.parseFromString(text, "text/html").body.textContent || "";
const cleanText = decoded.replace(/&nbsp;/g, " "); // Optionnel si besoin
return cleanText.length > maxLength ? `${cleanText.substring(0, maxLength)}...` : cleanText;
};
return (
<Box sx={{ padding: "40px 20px" }}>
<Typography variant="h2" sx={{ fontWeight: "bold", textAlign: "center", mb: 4, mt:5 }}>
IN3 Bureau d'études & Maîtrise d'oeuvre
<Typography variant="h2" sx={{ fontWeight: "bold", color:"#315397", textAlign: "center", mb: 4, mt:5 }}>
L'actualité du numérique
</Typography>
<Grid container spacing={4} justifyContent="center">