import Link from "next/link"; // Fonction pour récupérer tous les projets depuis l'API Strapi async function getAllprojects() { try { const response = await fetch("http://localhost:1337/api/projects?populate=*"); if (!response.ok) { throw new Error("Failed to fetch projects"); } const projects = await response.json(); return projects.data; } catch (error) { console.error("Error fetching projects:", error); return []; } } // Composant principal de la page des projets export default async function Page() { const projects = await getAllprojects(); // Déterminer la largeur du conteneur en fonction du nombre de projets let containerWidth = "max-w-4xl"; if (projects.length > 10) { containerWidth = "max-w-full"; } else if (projects.length > 5) { containerWidth = "max-w-6xl"; } else if (projects.length > 3) { containerWidth = "max-w-5xl"; } return (
{project.name}
{/* Affichage de la description du projet */}{project.description}