diff --git a/data/projects.json b/data/projects.json new file mode 100644 index 0000000..9757228 --- /dev/null +++ b/data/projects.json @@ -0,0 +1,55 @@ +{ + "projects": [ + { + "id": 1, + "title": "Site E-commerce XYZ", + "slug": "ecommerce-xyz", + "category": "vedette", + "thumbnail": "ecommerce-xyz-thumb.webp", + "url": "https://example.com", + "github": "https://github.com/user/project", + "technologies": ["PHP", "JavaScript", "Tailwind CSS", "MySQL"], + "context": "Client souhaitant moderniser sa boutique en ligne pour améliorer l'expérience utilisateur et augmenter les conversions.", + "solution": "Développement d'une solution e-commerce sur mesure avec panier persistant, paiement sécurisé Stripe, et interface d'administration.", + "teamwork": "Projet réalisé en collaboration avec un designer UI/UX. J'ai pris en charge l'intégration et le développement backend.", + "duration": "3 mois", + "screenshots": [ + "ecommerce-xyz-screen-1.webp", + "ecommerce-xyz-screen-2.webp", + "ecommerce-xyz-screen-3.webp" + ] + }, + { + "id": 2, + "title": "Application de Gestion", + "slug": "app-gestion", + "category": "vedette", + "thumbnail": "app-gestion-thumb.webp", + "url": null, + "github": "https://github.com/user/app-gestion", + "technologies": ["React", "Node.js", "PostgreSQL", "Docker"], + "context": "Startup ayant besoin d'un outil interne pour gérer ses ressources et planifier ses projets.", + "solution": "Application web full-stack avec authentification, gestion des rôles, tableaux de bord et exports PDF.", + "teamwork": null, + "duration": "4 mois", + "screenshots": [ + "app-gestion-screen-1.webp" + ] + }, + { + "id": 3, + "title": "Site Vitrine Restaurant", + "slug": "restaurant-vitrine", + "category": "secondaire", + "thumbnail": "restaurant-thumb.webp", + "url": "https://restaurant-example.com", + "github": null, + "technologies": ["HTML", "CSS", "JavaScript"], + "context": "Restaurant local souhaitant une présence en ligne simple.", + "solution": null, + "teamwork": null, + "duration": "2 semaines", + "screenshots": [] + } + ] +} diff --git a/includes/functions.php b/includes/functions.php index 9e02a69..708a174 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -13,3 +13,82 @@ function include_template(string $name, array $data = []): void extract($data); include __DIR__ . "/../templates/{$name}.php"; } + +/** + * Charge et parse un fichier JSON + * @param string $filename Nom du fichier dans le dossier data/ + * @return array Données décodées ou tableau vide en cas d'erreur + */ +function loadJsonData(string $filename): array +{ + $path = __DIR__ . "/../data/{$filename}"; + + if (!file_exists($path)) { + error_log("JSON file not found: {$filename}"); + return []; + } + + $content = file_get_contents($path); + $data = json_decode($content, true); + + if (json_last_error() !== JSON_ERROR_NONE) { + error_log("JSON parse error in {$filename}: " . json_last_error_msg()); + return []; + } + + return $data; +} + +/** + * Récupère tous les projets + * @return array Liste des projets + */ +function getProjects(): array +{ + $data = loadJsonData('projects.json'); + return $data['projects'] ?? []; +} + +/** + * Récupère les projets par catégorie + * @param string $category Catégorie (vedette|secondaire) + * @return array Projets filtrés + */ +function getProjectsByCategory(string $category): array +{ + return array_filter(getProjects(), fn($p) => $p['category'] === $category); +} + +/** + * Récupère un projet par son slug + * @param string $slug Slug du projet + * @return array|null Projet ou null si non trouvé + */ +function getProjectBySlug(string $slug): ?array +{ + $projects = getProjects(); + foreach ($projects as $project) { + if ($project['slug'] === $slug) { + return $project; + } + } + return null; +} + +/** + * Récupère les technologies uniques de tous les projets + * @return array Liste triée des technologies + */ +function getAllTechnologies(): array +{ + $technologies = []; + foreach (getProjects() as $project) { + foreach ($project['technologies'] ?? [] as $tech) { + if (!in_array($tech, $technologies)) { + $technologies[] = $tech; + } + } + } + sort($technologies); + return $technologies; +} diff --git a/index.php b/index.php index 03506ca..9441378 100644 --- a/index.php +++ b/index.php @@ -49,6 +49,65 @@ include_template('navbar', compact('currentPage')); + + +
+
+
+

Explorez mon portfolio

+

+ Découvrez mes réalisations, compétences et parcours +

+
+ + +
+