Skip to content

Commit 5bd23d4

Browse files
committed
fix: sort focus areas by frequency instead of first-seen order
1 parent b679ebb commit 5bd23d4

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ghost-github-portfolio",
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"description": "Auto-sync GitHub repositories to a Ghost CMS portfolio page. Fetches repos, sorts by stars, generates cards with banners and badges, and updates Ghost via the Admin API.",
55
"type": "module",
66
"bin": {

src/generator.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,16 @@ export function generateFooter(
230230
const languages = [
231231
...new Set(allRepos.map((r) => r.language).filter(Boolean)),
232232
];
233-
const focusAreas = [
234-
...new Set(allRepos.flatMap((r) => r.topics).filter(Boolean)),
235-
]
233+
const topicCounts = new Map<string, number>();
234+
for (const repo of allRepos) {
235+
for (const t of repo.topics) {
236+
topicCounts.set(t, (topicCounts.get(t) ?? 0) + 1);
237+
}
238+
}
239+
const focusAreas = [...topicCounts.entries()]
240+
.sort((a, b) => b[1] - a[1])
236241
.slice(0, 8)
237-
.map((t) => t.charAt(0).toUpperCase() + t.slice(1));
242+
.map(([t]) => t.charAt(0).toUpperCase() + t.slice(1));
238243

239244
const lines: string[] = [];
240245
lines.push(`<strong>Total Stars:</strong>&nbsp;${totalStars}+`);

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ program
1414
.description(
1515
"Auto-sync GitHub repositories to a Ghost CMS portfolio page. Fetches repos, sorts by stars, generates cards with banners and badges, and updates Ghost via the Admin API.",
1616
)
17-
.version("0.3.4");
17+
.version("0.3.5");
1818

1919
program
2020
.command("sync")

0 commit comments

Comments
 (0)