--- import { getCollection, render } from "astro:content"; import { Image } from "astro:assets"; import Layout from "../../../layouts/main.astro"; const logos = import.meta.glob<{ default: ImageMetadata }>('../../../assets/images/companies/*.png', { eager: true }); function getLogo(filename?: string) { if (!filename) return null; const key = `../../../assets/images/companies/${filename}`; return logos[key]?.default ?? null; } function getInitials(company: string) { return company.split(/[\s-]+/).map(w => w[0]).filter(Boolean).slice(0, 2).join('').toUpperCase(); } const locale = "ar"; const experiences = (await getCollection("experiences")) .filter((e) => e.data.lang === locale && !e.data.draft) .sort((a, b) => (b.data.startDate > a.data.startDate ? 1 : -1)); const typeLabels: Record = { employment: 'وظيفة', freelance: 'مستقل', teaching: 'تدريس', community: 'مجتمع', entrepreneurship: 'ريادة أعمال', }; const typeColors: Record = { employment: { badge: 'type-badge-blue', border: 'type-border-blue', dot: 'bg-blue-400 border-blue-400/50' }, freelance: { badge: 'type-badge-amber', border: 'type-border-amber', dot: 'bg-amber-400 border-amber-400/50' }, teaching: { badge: 'type-badge-emerald', border: 'type-border-emerald', dot: 'bg-emerald-400 border-emerald-400/50' }, community: { badge: 'type-badge-pink', border: 'type-border-pink', dot: 'bg-pink-400 border-pink-400/50' }, entrepreneurship: { badge: 'type-badge-purple', border: 'type-border-purple', dot: 'bg-purple-400 border-purple-400/50' }, }; function formatMonth(dateStr: string) { const [year, month] = dateStr.split('-'); return new Date(parseInt(year), parseInt(month) - 1) .toLocaleDateString('ar-SA', { year: 'numeric', month: 'short' }); } function computeDuration(startStr: string, endStr?: string) { const [sy, sm] = startStr.split('-').map(Number); const end = endStr ? endStr.split('-').map(Number) : [new Date().getFullYear(), new Date().getMonth() + 1]; const totalMonths = (end[0] - sy) * 12 + (end[1] - sm); const years = Math.floor(totalMonths / 12); const months = totalMonths % 12; if (years === 0) return `${months} أشهر`; if (months === 0) return `${years} سنة`; return `${years} سنة ${months} أشهر`; } ---
برمجة

المسار

أكثر من 20 سنة من الخبرة في تطوير البرمجيات.

{experiences.map(async (exp) => { const { Content } = await render(exp); const isOngoing = !exp.data.endDate; const start = formatMonth(exp.data.startDate); const end = exp.data.endDate ? formatMonth(exp.data.endDate) : 'الحاضر'; const duration = computeDuration(exp.data.startDate, exp.data.endDate); const colors = typeColors[exp.data.type] || typeColors.employment; const label = typeLabels[exp.data.type] || exp.data.type; return (
{isOngoing &&
}
{getLogo(exp.data.logo) ? ( ) : (
{getInitials(exp.data.company)}
)}
{label} {start} — {end} · {duration} {exp.data.location && · {exp.data.location}}

{exp.data.role}

{exp.data.companyUrl ? ( {exp.data.company} ) : exp.data.company}

{exp.data.technologies && exp.data.technologies.length > 0 && (
{exp.data.technologies.map((tech: string) => ( {tech} ))}
)}
); })}