Skip to content

Commit abfeb61

Browse files
committed
fix: left-align footer stats, remove bulletpoints, count all repos
Footer stats now include all qualifying repos (including awesome lists) while cards still respect excludeAwesomeLists filter.
1 parent fb4d425 commit abfeb61

5 files changed

Lines changed: 30 additions & 36 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.2",
3+
"version": "0.3.3",
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: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -215,56 +215,48 @@ function inferTechStack(repo: GitHubRepo): string | null {
215215
}
216216

217217
export function generateFooter(
218-
repos: GitHubRepo[],
218+
allRepos: GitHubRepo[],
219219
config: Config,
220220
): string | null {
221221
if (!config.portfolio.footer.showStats && !config.portfolio.footer.showViewAll)
222222
return null;
223223

224-
const center = config.portfolio.centerContent;
225-
const align = center ? ' style="text-align:center;"' : "";
226-
const listStyle = center
227-
? ' style="list-style:none; padding:0; text-align:center;"'
228-
: "";
229-
230224
const parts: string[] = [];
231-
parts.push(`<h2${align}>GitHub Stats</h2>`);
225+
parts.push(`<h2>GitHub Stats</h2>`);
232226

233227
if (config.portfolio.footer.showStats) {
234-
const totalStars = repos.reduce((s, r) => s + r.stargazers_count, 0);
235-
const totalRepos = repos.length;
228+
const totalStars = allRepos.reduce((s, r) => s + r.stargazers_count, 0);
229+
const totalRepos = allRepos.length;
236230
const languages = [
237-
...new Set(repos.map((r) => r.language).filter(Boolean)),
231+
...new Set(allRepos.map((r) => r.language).filter(Boolean)),
238232
];
239233
const focusAreas = [
240-
...new Set(repos.flatMap((r) => r.topics).filter(Boolean)),
234+
...new Set(allRepos.flatMap((r) => r.topics).filter(Boolean)),
241235
]
242236
.slice(0, 8)
243237
.map((t) => t.charAt(0).toUpperCase() + t.slice(1));
244238

245-
parts.push(`<ul${listStyle}>`);
246239
parts.push(
247-
`<li><strong>Total Stars (featured):</strong>&nbsp;${totalStars}+</li>`,
240+
`<p><strong>Total Stars (featured):</strong>&nbsp;${totalStars}+</p>`,
248241
);
249242
parts.push(
250-
`<li><strong>Featured Repositories:</strong>&nbsp;${totalRepos}</li>`,
243+
`<p><strong>Featured Repositories:</strong>&nbsp;${totalRepos}</p>`,
251244
);
252245
if (languages.length > 0) {
253246
parts.push(
254-
`<li><strong>Primary Languages:</strong>&nbsp;${languages.join(", ")}</li>`,
247+
`<p><strong>Primary Languages:</strong>&nbsp;${languages.join(", ")}</p>`,
255248
);
256249
}
257250
if (focusAreas.length > 0) {
258251
parts.push(
259-
`<li><strong>Focus Areas:</strong>&nbsp;${focusAreas.join(", ")}</li>`,
252+
`<p><strong>Focus Areas:</strong>&nbsp;${focusAreas.join(", ")}</p>`,
260253
);
261254
}
262-
parts.push(`</ul>`);
263255
}
264256

265257
if (config.portfolio.footer.showViewAll) {
266258
parts.push(
267-
`<p${align}><a href="https://github.com/${config.github.username}?tab=repositories"><strong>View All Repositories &rarr;</strong></a></p>`,
259+
`<p><a href="https://github.com/${config.github.username}?tab=repositories"><strong>View All Repositories &rarr;</strong></a></p>`,
268260
);
269261
}
270262

src/github.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ export async function fetchRepos(
7878
.filter((r) => includeForked || !r.fork)
7979
.filter((r) => !excludeSet.has(r.name.toLowerCase()))
8080
.filter((r) => !config.portfolio.repos[r.name]?.exclude)
81-
.filter((r) => {
82-
if (!config.portfolio.excludeAwesomeLists) return true;
83-
return !r.name.toLowerCase().startsWith("awesome") && !r.topics.includes("awesome-list");
84-
})
8581
.sort((a, b) => b.stargazers_count - a.stargazers_count)
8682
.slice(0, maxRepos);
8783
}

src/index.ts

Lines changed: 16 additions & 10 deletions
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.2");
17+
.version("0.3.3");
1818

1919
program
2020
.command("sync")
@@ -34,20 +34,26 @@ program
3434
console.log(
3535
`Fetching repos for ${config.github.username} (min ${config.portfolio.minStars} stars)...`,
3636
);
37-
const repos = await fetchRepos(config);
37+
const allRepos = await fetchRepos(config);
38+
39+
// Filter awesome lists for display only (stats use all repos)
40+
const displayRepos = config.portfolio.excludeAwesomeLists
41+
? allRepos.filter((r) => !r.name.toLowerCase().startsWith("awesome") && !r.topics.includes("awesome-list"))
42+
: allRepos;
43+
3844
console.log(
39-
`Found ${repos.length} repos matching criteria (${config.portfolio.minStars}+ stars)`,
45+
`Found ${allRepos.length} repos matching criteria (${config.portfolio.minStars}+ stars)${displayRepos.length < allRepos.length ? `, displaying ${displayRepos.length}` : ""}`,
4046
);
4147

42-
if (repos.length === 0) {
48+
if (displayRepos.length === 0) {
4349
console.log("No repos found. Check your config.");
4450
return;
4551
}
4652

4753
// Detect banners (parallel)
4854
if (verbose) console.log("Detecting banner images...");
4955
const bannerResults = await Promise.all(
50-
repos.map(async (repo) => {
56+
displayRepos.map(async (repo) => {
5157
const banner = await detectBanner(repo, config);
5258
if (verbose) {
5359
console.log(
@@ -61,7 +67,7 @@ program
6167
// Fetch per-repo portfolio configs (.ghost-portfolio.yml)
6268
if (verbose) console.log("Fetching portfolio configs...");
6369
await Promise.all(
64-
repos.map(async (repo) => {
70+
displayRepos.map(async (repo) => {
6571
const portfolioConfig = await fetchPortfolioConfig(repo, config);
6672
if (portfolioConfig) {
6773
// Merge: per-repo file provides defaults, config.yml overrides
@@ -82,7 +88,7 @@ program
8288
generateCard(repo, banner, config),
8389
);
8490

85-
const footer = generateFooter(repos, config);
91+
const footer = generateFooter(allRepos, config);
8692
const lexical = buildLexical(cards, footer);
8793

8894
if (opts.json) {
@@ -99,7 +105,7 @@ program
99105
}
100106
console.log(`\nTotal cards: ${cards.length}`);
101107
console.log(
102-
`Total stars: ${repos.reduce((s, r) => s + r.stargazers_count, 0)}`,
108+
`Total stars: ${displayRepos.reduce((s, r) => s + r.stargazers_count, 0)}`,
103109
);
104110

105111
// Write to temp file for inspection
@@ -121,9 +127,9 @@ program
121127
const updated = await updatePage(config, page.id, page.updated_at, lexical);
122128

123129
console.log(`Portfolio updated: ${updated.title}`);
124-
console.log(` ${repos.length} projects displayed`);
130+
console.log(` ${displayRepos.length} projects displayed`);
125131
console.log(
126-
` ${repos.reduce((s, r) => s + r.stargazers_count, 0)} total stars`,
132+
` ${displayRepos.reduce((s, r) => s + r.stargazers_count, 0)} total stars`,
127133
);
128134
console.log(
129135
` ${bannerResults.filter((b) => b.banner).length} banners loaded`,

0 commit comments

Comments
 (0)