async function GetSkills() { const res = await fetch(`${process.env.BACKEND_URL}/cv/skills`, { cache: process.env.CACHE }); if (!res.ok) { throw new Error("Erreur lors du chargement des skills du CV"); } return res.json(); } export default async function Skills(){ const data = await GetSkills(); // Support both array and object responses from the backend and merge all items if array let obj: Record = {}; if (Array.isArray(data)) { for (const item of data) { if (item && typeof item === "object") { for (const [category, items] of Object.entries(item as Record)) { if (Array.isArray(items)) { obj[category] = [...(obj[category] ?? []), ...items.filter((x): x is string => typeof x === "string")]; } } } } // Deduplicate items per category obj = Object.fromEntries( Object.entries(obj).map(([k, arr]) => [k, Array.from(new Set(arr))]) ); } else if (data && typeof data === "object") { obj = data as Record; } const entries = Object.entries(obj) as [string, string[]][]; if (entries.length === 0) { return (

Mes compétences

Aucune compétence à afficher.

); } return ( /* * {mySkillsEntries.length > 0 && (

Compétences clés

    {mySkillsEntries.map(([category, items]) => (
  • {category}

    {items.map((it) => ( {it} ))}
  • ))}
)} * */

Mes compétences

    {entries.map(([category, skills]) => (
  • {category}

    {skills.map((skill: string) => ( {skill} ))}
  • ))}
); }