document.addEventListener("DOMContentLoaded", function () { async function setCard(el, url, name, labels, version, theme, authors) { const colorList = [ "#22c55e", "#14b8a6", "#ef4444", "#eab308", "#8b5cf6", "#f97316", "#3b82f6", ] let labelHTML = '' if (labels) { const labelArray = labels.split(',').map((label, index) => { const color = colorList[index % colorList.length] return `${label}` }) labelHTML = labelArray.join(' ') } const authorArray = authors.split(','); const authorDataArray = await Promise.all(authorArray.map(async (author) => { const response = await fetch(`https://api.github.com/users/${author.trim()}`); return await response.json(); })); let authorAvatarsHTML = authorDataArray.map((authorData, index) => { const marginLeft = index === 0 ? '0' : '-10px'; const zIndex = 100 - index; return `
${authorData.login}'s avatar
`; }).join(''); let authorNamesHTML = authorDataArray.map( authorData => ` ${authorData.login} ` ).join(', '); let authorsHTML = `
${authorAvatarsHTML}
${authorNamesHTML}
`; el.innerText = `
${name}
${authorsHTML}
  ${version}
${labelHTML}
` let sanitizedHTML = DOMPurify.sanitize(el.innerText); el.innerHTML = sanitizedHTML; } for (const el of document.querySelectorAll('.repo-card')) { const url = el.getAttribute('data-url'); const name = el.getAttribute('data-name'); const labels = el.getAttribute('data-labels'); const version = el.getAttribute('data-version'); const authors = el.getAttribute('data-author'); const palette = __md_get("__palette") if (palette && typeof palette.color === "object") { var theme = palette.color.scheme === "slate" ? "dark-theme" : "light-default" } else { var theme = "light-default" } setCard(el, url, name, labels, version, theme, authors); } })