Skip to content

Commit 5029941

Browse files
committed
fix issue labeels for fetch
1 parent f45014d commit 5029941

File tree

2 files changed

+57
-42
lines changed

2 files changed

+57
-42
lines changed

src/components/IssueList.astro

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,53 @@ async function fetchIssues(owner: string, repo: string) {
3232
headers['Authorization'] = `Bearer ${githubToken}`;
3333
}
3434
35-
// Try a single request with both labels first
36-
const labels = 'good first issue,help wanted';
37-
const encodedLabels = encodeURIComponent(labels);
38-
const url = `https://api.github.com/repos/${owner}/${repo}/issues?labels=${encodedLabels}&state=open&per_page=10&sort=updated`;
35+
// Try multiple requests for different label combinations
36+
const labelCombinations = [
37+
'good first issue,help wanted', // Both labels
38+
'good first issue', // Just good first issue
39+
'help wanted' // Just help wanted
40+
];
3941
40-
const response = await fetch(url, { headers });
42+
let allIssues: any[] = [];
4143
42-
if (response.status === 403) {
43-
return [];
44-
}
45-
46-
if (!response.ok) {
47-
if (response.status === 404) {
44+
for (const labels of labelCombinations) {
45+
const encodedLabels = encodeURIComponent(labels);
46+
const url = `https://api.github.com/repos/${owner}/${repo}/issues?labels=${encodedLabels}&state=open&per_page=10&sort=updated`;
47+
48+
const response = await fetch(url, { headers });
49+
50+
if (response.status === 403) {
4851
return [];
4952
}
50-
throw new Error(`GitHub API responded with status: ${response.status}`);
53+
54+
if (!response.ok) {
55+
if (response.status === 404) {
56+
continue; // Try next combination
57+
}
58+
continue; // Try next combination
59+
}
60+
61+
const issues = await response.json();
62+
63+
allIssues = [...allIssues, ...issues];
64+
65+
// If we found issues, break to avoid duplicates
66+
if (issues.length > 0) {
67+
break;
68+
}
5169
}
5270
53-
const issues = await response.json();
71+
// Remove duplicates based on issue number
72+
const uniqueIssues = allIssues.filter((issue, index, self) =>
73+
index === self.findIndex(i => i.number === issue.number)
74+
);
5475
55-
if (issues.length === 0) {
76+
if (uniqueIssues.length === 0) {
5677
return [];
5778
}
5879
5980
// Process and prioritize issues
60-
const processedIssues = issues.map((issue: any) => {
81+
const processedIssues = uniqueIssues.map((issue: any) => {
6182
const hasGoodFirstIssue = issue.labels.some((label: any) =>
6283
label.name.toLowerCase().includes('good first issue') ||
6384
label.name.toLowerCase().includes('good-first-issue')
@@ -94,7 +115,6 @@ if (repoInfo) {
94115
<div class="Card-Issues">
95116
<div class="Issues-Header">
96117
<h4 class="Issues-Title">Open Issues</h4>
97-
<span class="Issues-Count">{issues.length}</span>
98118
</div>
99119

100120
{issues.length > 0 ? (
@@ -120,9 +140,9 @@ if (repoInfo) {
120140
</div>
121141
) : (
122142
<div class="no-issues">
123-
<div class="no-issues-icon">🔍</div>
124-
<div class="no-issues-text">No issues found</div>
125-
<div class="no-issues-subtext">Try checking back later</div>
143+
<div class="no-issues-icon">🎉</div>
144+
<div class="no-issues-text">No beginner-friendly issues</div>
145+
<div class="no-issues-subtext">All good first issues and help wanted tasks are currently taken! Check back later for new opportunities.</div>
126146
</div>
127147
)}
128148
</div>

src/data/projects.js

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ export const projectList = [
3535
loadIssues: true,
3636
tags: ["design", "opensourcedesign", "open-source", "open-source-design"],
3737
},
38+
{
39+
name: "Open Source Diversity",
40+
imageSrc: "https://avatars1.githubusercontent.com/u/31018274?s=200&v=4",
41+
projectLink:
42+
"https://github.com/opensourcediversity/opensourcediversity.org/contribute",
43+
description:
44+
"For more diversity & inclusion in free & open source software communities 😊",
45+
tags: [
46+
"javascript",
47+
"html",
48+
"css",
49+
"diversity",
50+
"inclusion",
51+
"🎉",
52+
"web",
53+
"community",
54+
],
55+
},
3856
{
3957
name: "appsmith",
4058
imageSrc:
@@ -277,21 +295,6 @@ export const projectList = [
277295
"Unified command-line interface for linting and fixing all your code.",
278296
tags: ["Python", "Linting", "Code Quality"],
279297
},
280-
{
281-
name: "Moment",
282-
imageSrc: "https://avatars2.githubusercontent.com/u/4129662?v=3&s=100",
283-
projectLink: "https://github.com/moment/moment/contribute",
284-
description:
285-
"Parse, validate, manipulate, and display dates in JavaScript.",
286-
tags: ["JavaScript", "Date", "Library"],
287-
},
288-
{
289-
name: "Leiningen",
290-
imageSrc: "https://leiningen.org/img/leiningen.jpg",
291-
projectLink: "https://github.com/technomancy/leiningen/contribute",
292-
description: "Automate Clojure projects without setting your hair on fire.",
293-
tags: ["Clojure", "Build Tool", "Automation"],
294-
},
295298
{
296299
name: "Webpack",
297300
imageSrc: "https://avatars3.githubusercontent.com/u/2105791?v=3&s=100",
@@ -321,14 +324,6 @@ export const projectList = [
321324
description: "Vim-fork focused on extensibility and usability.",
322325
tags: ["Vim", "Editor", "Cross Platform"],
323326
},
324-
{
325-
name: "Hoodie",
326-
imageSrc:
327-
"https://hoodiehq.github.io/hoodie-css/src/content_img/animals/low-profile-dog-1.png",
328-
projectLink: "https://github.com/hoodiehq/hoodie/contribute",
329-
description: "The Offline First JavaScript Backend.",
330-
tags: ["JavaScript", "Node.js", "Web Development"],
331-
},
332327
{
333328
name: "freeCodeCamp",
334329
imageSrc: "https://avatars0.githubusercontent.com/u/9892522?v=3&s=100",

0 commit comments

Comments
 (0)