maj du texte des articles

This commit is contained in:
sebvtl728
2025-01-31 22:40:52 +01:00
parent 827a6ac092
commit 55436deb95
2 changed files with 7 additions and 4 deletions
@@ -70,7 +70,7 @@ const GestionArticles = () => {
// ✅ Filtrage des articles // ✅ Filtrage des articles
const filteredPosts = posts.filter((post) => const filteredPosts = posts.filter((post) =>
post.title.rendered.toLowerCase().includes(searchTerm.toLowerCase()) || post.title.rendered.toLowerCase().includes(searchTerm.toLowerCase()) ||
post.excerpt.rendered.replace(/(<([^>]+)>)/gi, "").toLowerCase().includes(searchTerm.toLowerCase()) post.excerpt.rendered.replace(/(<([^>]+)>)/gi, "").replace(/&nbsp;/g, " ").toLowerCase().includes(searchTerm.toLowerCase())
); );
return ( return (
@@ -125,7 +125,7 @@ const GestionArticles = () => {
<TableCell sx={{ fontWeight: "bold" }}>{post.title.rendered}</TableCell> <TableCell sx={{ fontWeight: "bold" }}>{post.title.rendered}</TableCell>
{/* ✅ Résumé avec 100 caractères max */} {/* ✅ Résumé avec 100 caractères max */}
<TableCell> <TableCell>
{post.excerpt.rendered.replace(/(<([^>]+)>)/gi, "").substring(0, 100)}... {post.excerpt.rendered.replace(/(<([^>]+)>)/gi, "").replace(/&nbsp;/g, " ").substring(0, 100)}...
</TableCell> </TableCell>
{/* ✅ Boutons Modifier et Supprimer */} {/* ✅ Boutons Modifier et Supprimer */}
<TableCell sx={{ textAlign: "center" }}> <TableCell sx={{ textAlign: "center" }}>
+5 -2
View File
@@ -45,13 +45,16 @@ const Posts = () => {
// 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); // Nettoyage HTML 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; return strippedText.length > maxLength ? `${strippedText.substring(0, maxLength)}...` : strippedText;
}; };
return ( return (
<Box sx={{ padding: "40px 20px" }}> <Box sx={{ padding: "40px 20px" }}>
<Typography variant="h2" sx={{ fontWeight: "bold", textAlign: "center", mb: 4 }}> <Typography variant="h2" sx={{ fontWeight: "bold", textAlign: "center", mb: 4, mt:5 }}>
Nos Articles Nos Articles
</Typography> </Typography>