bug affichage post
This commit is contained in:
@@ -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(/ /g, " ") // Remplace les espaces non bris
|
|
||||||
); // Nettoyage HTML
|
const cleanText = decoded.replace(/ /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">
|
||||||
|
|||||||
Reference in New Issue
Block a user