bug affichage post

This commit is contained in:
sebvtl728
2025-07-31 20:15:17 +02:00
parent 51195ac398
commit 7c01c6e81d
+17 -9
View File
@@ -43,19 +43,27 @@ const Posts = () => {
return html.replace(/(<([^>]+)>)/gi, ""); // Supprime toutes les balises HTML 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 // Fonction pour tronquer un texte à 100 caractères max
const truncateText = (text, maxLength) => { const truncateText = (text, maxLength) => {
const strippedText = stripHtmlTags(text const parser = new DOMParser();
.replace(/<[^>]*>/g, "") // Supprime les balises HTML const decoded = parser.parseFromString(text, "text/html").body.textContent || "";
.replace(/&nbsp;/g, " ") // Remplace les espaces non bris
); // Nettoyage HTML const cleanText = decoded.replace(/&nbsp;/g, " "); // Optionnel si besoin
return strippedText.length > maxLength ? `${strippedText.substring(0, maxLength)}...` : strippedText; return cleanText.length > maxLength ? `${cleanText.substring(0, maxLength)}...` : cleanText;
}; };
return ( return (
<Box sx={{ padding: "40px 20px" }}> <Box sx={{ padding: "40px 20px" }}>
<Typography variant="h2" sx={{ fontWeight: "bold", textAlign: "center", mb: 4, mt:5 }}> <Typography variant="h2" sx={{ fontWeight: "bold", color:"#315397", textAlign: "center", mb: 4, mt:5 }}>
IN3 Bureau d'études & Maîtrise d'oeuvre L'actualité du numérique
</Typography> </Typography>
<Grid container spacing={4} justifyContent="center"> <Grid container spacing={4} justifyContent="center">