Skip to content

Commit 01949f6

Browse files
amide-initclaude
andcommitted
feat: generate rich dynamic hero description from repo data in preview
Replaces the plain hardcoded fallback with a description computed from the user's actual GitHub data — total stars, top languages, and top topics — matching the style used by the CLI generator. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e9271ef commit 01949f6

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/components/PortfolioPreviewModal.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,37 @@ export type PreviewRepo = {
3838
// ── Data builders — convert GitHub API → threejs template prop shapes ─────────
3939

4040
function buildHero(user: PreviewUser, allRepos: PreviewRepo[]) {
41-
const topLangs = [
42-
...new Set(allRepos.map((r) => r.language).filter(Boolean)),
43-
].slice(0, 5)
41+
// Top languages by repo count
42+
const langCounts: Record<string, number> = {}
43+
allRepos.forEach((r) => { if (r.language) langCounts[r.language] = (langCounts[r.language] ?? 0) + 1 })
44+
const topLangs = Object.entries(langCounts).sort((a, b) => b[1] - a[1]).map(([l]) => l).slice(0, 5)
45+
46+
// Top topics by frequency
47+
const topicCounts: Record<string, number> = {}
48+
allRepos.forEach((r) => (r.topics ?? []).forEach((t) => { topicCounts[t] = (topicCounts[t] ?? 0) + 1 }))
49+
const topTopics = Object.entries(topicCounts).sort((a, b) => b[1] - a[1]).map(([t]) => t).slice(0, 3)
50+
51+
const totalStars = allRepos.reduce((s, r) => s + r.stargazers_count, 0)
4452

4553
const eyebrow = user.company
4654
? `Working at ${user.company}`
4755
: topLangs.length
4856
? topLangs.join(' · ')
4957
: 'GitHub Developer'
5058

51-
const description =
52-
user.bio ||
53-
`${user.name || user.login} maintains ${user.public_repos} public repositories on GitHub.`
59+
// Build a rich auto-generated description (same style as the CLI generator)
60+
const name = user.name || user.login
61+
let generated = `${name} maintains ${user.public_repos} public repositories on GitHub`
62+
if (totalStars > 0) generated += ` with ${totalStars.toLocaleString()} star${totalStars === 1 ? '' : 's'} across these projects`
63+
generated += '.'
64+
if (topLangs.length) generated += ` Most of the work centers around ${topLangs[0]}`
65+
if (topTopics.length) generated += `, with repositories touching topics like ${topTopics.join(', ')}`
66+
if (topLangs.length || topTopics.length) generated += '.'
67+
68+
// Use the user's own bio if they have one, otherwise use the generated description
69+
const description = user.bio
70+
? `${user.bio}\n\n${generated}`
71+
: generated
5472

5573
const social: { provider: string; url: string }[] = []
5674
if (user.twitter_username)

0 commit comments

Comments
 (0)