From d5f6bc70ef03c9c5591f793535872591d34f57d8 Mon Sep 17 00:00:00 2001 From: Mark Daugherty Date: Tue, 21 Apr 2026 10:53:46 -0500 Subject: [PATCH] fix: github repos --- blocks/github-repos/github-repos.js | 51 ++--------------------------- styles/styles.css | 4 --- 2 files changed, 3 insertions(+), 52 deletions(-) diff --git a/blocks/github-repos/github-repos.js b/blocks/github-repos/github-repos.js index 792fc75..2bee101 100644 --- a/blocks/github-repos/github-repos.js +++ b/blocks/github-repos/github-repos.js @@ -1,21 +1,3 @@ -/** - * Parses the key/value configuration rows authored into the block. - * @param {Element} block The block element - * @returns {Object} Configuration object - */ -function parseConfig(block) { - const config = {}; - block.querySelectorAll(':scope > div').forEach((row) => { - const cells = row.querySelectorAll(':scope > div'); - if (cells.length === 2) { - const key = cells[0].textContent.trim().toLowerCase(); - const value = cells[1].textContent.trim(); - if (key) config[key] = value; - } - }); - return config; -} - /** * Creates a status message paragraph and replaces block contents with it. * @param {Element} block The block element @@ -121,19 +103,6 @@ function buildCard(repo) { * @param {Element} block The block element */ export default async function decorate(block) { - const { - username, - limit = '6', - topic = '', - sort = 'updated', - } = parseConfig(block); - - if (!username) { - showMessage(block, 'github-repos-error', 'No GitHub username configured.'); - return; - } - - const limitNum = parseInt(limit, 10) || 6; const isList = block.classList.contains('list'); // Show loading state while fetching @@ -144,27 +113,13 @@ export default async function decorate(block) { block.replaceChildren(loading); try { - const response = await fetch(`/data/github-repos/${encodeURIComponent(username)}.json`); + const response = await fetch('/data/github-repos/repos.json'); if (!response.ok) { throw new Error(`Failed to load repo data: ${response.status}`); } - let repos = await response.json(); - - // Client-side topic filter - if (topic) { - repos = repos.filter((repo) => Array.isArray(repo.topics) && repo.topics.includes(topic)); - } - - // Client-side sort for stars and name - if (sort === 'stars') { - repos.sort((a, b) => b.stargazers_count - a.stargazers_count); - } else if (sort === 'name') { - repos.sort((a, b) => a.name.localeCompare(b.name)); - } - - repos = repos.slice(0, limitNum); + const repos = await response.json(); if (repos.length === 0) { showMessage(block, 'github-repos-empty', 'No repositories found.'); @@ -173,7 +128,7 @@ export default async function decorate(block) { const ul = document.createElement('ul'); ul.className = isList ? 'github-repos-list' : 'github-repos-grid'; - ul.setAttribute('aria-label', `${username} repositories`); + ul.setAttribute('aria-label', 'GitHub Repositories'); repos.forEach((repo) => ul.append(buildCard(repo))); diff --git a/styles/styles.css b/styles/styles.css index 4f6cd85..5a8d793 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -98,10 +98,6 @@ h6 { scroll-margin: 40px; } -h3 { - margin-bottom: 0.8em; -} - h1 { font-size: var(--heading-font-size-xxl); } h2 { font-size: var(--heading-font-size-xl); } h3 { font-size: var(--heading-font-size-l); }