document.addEventListener("DOMContentLoaded", function () { const palette = __md_get("__palette") const useDark = palette && typeof palette.color === "object" && palette.color.scheme === "slate" const theme = useDark ? "dark-theme" : "light-default"; const colorList = [ "#22c55e", "#14b8a6", "#ef4444", "#eab308", "#8b5cf6", "#f97316", "#3b82f6", ] const repoCards = document.querySelectorAll(".repo-card"); const labelsAll = Array .from(repoCards) .flatMap((element) => element.getAttribute('data-labels').split(',')) .map(label => label.trim()) .filter(label => label !== ''); const uniqueLabels = [...new Set(labelsAll)]; const labelToColor = uniqueLabels.reduce((map, label, index) => { map[label] = colorList[index % colorList.length]; return map; }, {}); async function renderCard(element, elementIndex) { const name = element.getAttribute('data-name'); const labels = element.getAttribute('data-labels'); const version = element.getAttribute('data-version'); const authors = element.getAttribute('data-author'); const labelHTML = labels ? labels.split(',').filter(label => label !== '').map((label, index) => { const color = labelToColor[label.trim()]; return ` ${label.trim()} `; }).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 = 4 - index; return `
`; }).join(''); let authorNamesHTML = authorDataArray.map( authorData => ` ` ).join(', '); let authorsHTML = ` `; element.innerText = `