Skip to content

Commit 994530b

Browse files
authored
Merge pull request #5 from CodeYogiCo/feat/pinned-repos
Add pinned GitHub repos section on the index
2 parents 9298245 + eb70b10 commit 994530b

3 files changed

Lines changed: 104 additions & 0 deletions

File tree

‎src/App.jsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { profile } from './data'
55
import { posts, visiblePosts } from './loadPosts'
66
import { widgets } from './widgets'
77
import ViewCount from './widgets/ViewCount.jsx'
8+
import PinnedRepos from './widgets/PinnedRepos.jsx'
89

910
const lastEdit = visiblePosts[0]?.date || posts[0]?.date || ''
1011

@@ -371,6 +372,7 @@ function Index() {
371372
<Identity />
372373
<About />
373374
<PostsList />
375+
<PinnedRepos />
374376
<Footer />
375377
</main>
376378
)

‎src/index.css‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,50 @@ a:hover {
218218
}
219219
.posts li:hover .read { color: var(--accent); }
220220

221+
/* ── pinned repos ──────────────────────────────────────── */
222+
223+
.pinned { margin-top: 60px; }
224+
.pinned-title {
225+
font-size: 12px;
226+
font-weight: 500;
227+
text-transform: lowercase;
228+
letter-spacing: 0.06em;
229+
color: var(--ink-faint);
230+
margin: 0 0 14px;
231+
}
232+
.pinned-title::before { content: "## "; }
233+
.pinned-list { list-style: none; margin: 0; padding: 0; }
234+
.pinned-list li {
235+
border-top: 1px dashed var(--rule);
236+
padding: 10px 0;
237+
}
238+
.pinned-list li:last-child { border-bottom: 1px dashed var(--rule); }
239+
.pinned-card { display: block; border-bottom: 0; }
240+
.pinned-card:hover .pinned-name { color: var(--accent); }
241+
.pinned-row {
242+
display: flex;
243+
align-items: baseline;
244+
justify-content: space-between;
245+
gap: 12px;
246+
font-size: 13.5px;
247+
}
248+
.pinned-name { font-weight: 500; }
249+
.pinned-meta {
250+
display: inline-flex;
251+
gap: 12px;
252+
font-size: 11.5px;
253+
color: var(--ink-faint);
254+
white-space: nowrap;
255+
}
256+
.pinned-lang { color: var(--accent); letter-spacing: 0.04em; }
257+
.pinned-stars { font-variant-numeric: tabular-nums; }
258+
.pinned-desc {
259+
margin-top: 3px;
260+
font-size: 12.5px;
261+
color: var(--ink-soft);
262+
line-height: 1.5;
263+
}
264+
221265
/* ── footer ────────────────────────────────────────────── */
222266

223267
.footer {

‎src/widgets/PinnedRepos.jsx‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { useEffect, useState } from 'react'
2+
3+
const ENDPOINT = 'https://gh-pinned-repos.egoist.dev/?username=codeyogico'
4+
5+
function clean(r) {
6+
const repo = (r.repo || '').trim()
7+
const link = (r.link || '').trim() || `https://github.com/${r.owner}/${repo}`
8+
return {
9+
owner: r.owner,
10+
repo,
11+
link: link.replace(/\s+/g, ''),
12+
description: (r.description || '').trim(),
13+
language: (r.language || '').trim(),
14+
stars: Number(r.stars) || 0,
15+
}
16+
}
17+
18+
export default function PinnedRepos() {
19+
const [repos, setRepos] = useState(null)
20+
21+
useEffect(() => {
22+
let cancelled = false
23+
fetch(ENDPOINT)
24+
.then((r) => (r.ok ? r.json() : null))
25+
.then((data) => {
26+
if (cancelled || !Array.isArray(data)) return
27+
setRepos(data.map(clean).filter((r) => r.repo))
28+
})
29+
.catch(() => {})
30+
return () => {
31+
cancelled = true
32+
}
33+
}, [])
34+
35+
if (!repos || repos.length === 0) return null
36+
37+
return (
38+
<section className="pinned">
39+
<h2 className="pinned-title">github</h2>
40+
<ul className="pinned-list">
41+
{repos.map((r) => (
42+
<li key={`${r.owner}/${r.repo}`}>
43+
<a href={r.link} target="_blank" rel="noopener noreferrer" className="pinned-card">
44+
<div className="pinned-row">
45+
<span className="pinned-name">{r.repo}</span>
46+
<span className="pinned-meta">
47+
{r.language && <span className="pinned-lang">{r.language}</span>}
48+
{r.stars > 0 && <span className="pinned-stars">★ {r.stars}</span>}
49+
</span>
50+
</div>
51+
{r.description && <div className="pinned-desc">{r.description}</div>}
52+
</a>
53+
</li>
54+
))}
55+
</ul>
56+
</section>
57+
)
58+
}

0 commit comments

Comments
 (0)