"use client"; import { useState, useEffect } from 'react'; import { motion } from 'framer-motion'; import { ExternalLink, Github, Calendar } from 'lucide-react'; import Link from 'next/link'; interface Project { id: number; title: string; description: string; content: string; tags: string[]; featured: boolean; category: string; date: string; github?: string; live?: string; } const Projects = () => { const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); }, []); const [projects, setProjects] = useState([]); // Load projects from API useEffect(() => { const loadProjects = async () => { try { const response = await fetch('/api/projects?featured=true&published=true&limit=6'); if (response.ok) { const data = await response.json(); setProjects(data.projects || []); } else { console.error('Failed to fetch projects from API'); } } catch (error) { console.error('Error loading projects:', error); } }; loadProjects(); }, []); if (!mounted) { return null; } return (

Featured Projects

Here are some of my recent projects that showcase my skills and passion for creating innovative solutions.

{projects.map((project, index) => (
{project.title.split(' ').map(word => word[0]).join('').toUpperCase().slice(0, 2)} {project.title}
{project.featured && ( ⭐ Featured )}
{project.github && project.github.trim() !== '' && project.github !== '#' && ( )} {project.live && project.live.trim() !== '' && project.live !== '#' && ( )}

{project.title}

{new Date(project.date).getFullYear()}

{project.description}

{project.tags.slice(0, 4).map((tag) => ( {tag} ))} {project.tags.length > 4 && ( +{project.tags.length - 4} )}
View Details
))}
View All Projects
); }; export default Projects;