async function getNpmPackageStats(packageName) { const end = new Date().toJSON().split("T")[0]; return await fetch( `https://api.npmjs.org/downloads/point/last-year/${packageName}` ).then((r) => r.json()); } async function myOwnProjectsRender() { const el = document.getElementById("my-own-projects"); const myOwnProjects = await fetch("/my-own-projects.json").then((res) => res.json() ); const render = () => { let str = ""; myOwnProjects.projects.forEach((project, ind) => { str += `
`; }); el.innerHTML = str; }; render(); const npmLibs = myOwnProjects.projects.filter((project) => project.tags?.includes("npm") ); for (const project of npmLibs) { const packageName = project.url.split("/package/")[1]; const stat = await getNpmPackageStats(packageName).catch((err) => { console.error(`Error fetching NPM stats for ${packageName}:`, err); return null; }); if (stat) { project.description = `${ project.description }\n\n📦 NPM Downloads (last year): ${stat.downloads.toLocaleString( "en-US" )}`; } } render(); } async function myParticipationRender() { const el = document.getElementById("my-participation"); const myParticipation = await fetch("/my-participation.json").then((res) => res.json() ); let str = ""; myParticipation.projects.forEach((project, ind) => { str += ``; }); el.innerHTML = str; } async function myTestimonialsRender() { const el = document.getElementById("my-testimonials"); const myTestimonials = await fetch("/my-testimonials.json").then((res) => res.json() ); let str = ""; myTestimonials.testimonials.forEach((testimonial, ind) => { str += `${testimonial.comment.replace(
/\n/gi,
"
"
)}