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 logoSrc = (document.querySelector('link[rel="icon"]') || {}).href || ''; const authorCache = {}; 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 description = element.getAttribute('data-description') || ''; 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 ? authors.split(',').filter(a => a.trim()) : []; const authorDataArray = await Promise.all(authorArray.map(async (author) => { const login = author.trim(); if (authorCache[login]) return authorCache[login]; try { const response = await fetch(`https://api.github.com/users/${login}`); if (!response.ok) return { login, avatar_url: `https://github.com/${login}.png` }; const data = await response.json(); authorCache[login] = data; return data; } catch { return { login, avatar_url: `https://github.com/${login}.png` }; } })); let authorAvatarsHTML = authorDataArray.map((authorData, index) => { const marginLeft = index === 0 ? '0' : '-10px'; return `
`; }).join(''); let authorNamesHTML = authorDataArray.map( authorData => ` ` ).join(', '); let authorsHTML = ` `; const rawHTML = `${description}
` : ''} ${authorsHTML}