Skip to content

Commit 96a0dbe

Browse files
author
Yogthos
committed
nav: replace text link with a real GitHub-style star button (octicon + live count)
1 parent d96f24e commit 96a0dbe

1 file changed

Lines changed: 52 additions & 7 deletions

File tree

‎index.html‎

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,39 @@
134134
.nav-links a:hover{color:var(--fg-hi);text-decoration:none}
135135

136136
.nav-right{margin-left:auto;display:flex;gap:10px;align-items:center}
137-
.nav-gh{
138-
color:var(--fg-dim);text-decoration:none;
139-
font-size:11px;letter-spacing:0.06em;font-family:var(--mono);
140-
border:1px solid var(--border);
141-
padding:5px 12px;transition:all 0.18s;border-radius:4px;
137+
138+
/* GitHub-style star button: [★ Star] [count] with the connecting caret */
139+
.gh-star{
140+
display:inline-flex;align-items:stretch;
141+
font-size:12px;font-weight:600;line-height:1;
142+
text-decoration:none;color:var(--fg);
143+
}
144+
.gh-star:hover{text-decoration:none}
145+
.gh-star-btn{
146+
display:inline-flex;align-items:center;gap:6px;
147+
padding:5px 10px;
148+
color:var(--fg);background:var(--bg2);
149+
border:1px solid var(--border);border-radius:6px 0 0 6px;
150+
transition:background 0.15s,border-color 0.15s;
151+
}
152+
.gh-star-btn svg{width:14px;height:14px;fill:currentColor}
153+
.gh-star:hover .gh-star-btn{background:var(--bg3);border-color:var(--fg-dim)}
154+
.gh-star-count{
155+
display:none;align-items:center;position:relative;
156+
padding:5px 10px;margin-left:7px;
157+
color:var(--fg);background:var(--bg);
158+
border:1px solid var(--border);border-radius:6px;
159+
font-variant-numeric:tabular-nums;
160+
}
161+
/* the little triangle that points from the count box back at the button */
162+
.gh-star-count::before{
163+
content:"";position:absolute;left:-7px;top:50%;transform:translateY(-50%);
164+
border:7px solid transparent;border-right-color:var(--border);border-left:0;
165+
}
166+
.gh-star-count::after{
167+
content:"";position:absolute;left:-6px;top:50%;transform:translateY(-50%);
168+
border:6px solid transparent;border-right-color:var(--bg);border-left:0;
142169
}
143-
.nav-gh:hover{color:var(--fg-hi);border-color:var(--fg-dim);text-decoration:none}
144170

145171
/* ─── SECTIONS ──────────────────────────────────────────────── */
146172
.sec{
@@ -488,7 +514,13 @@
488514
<a href="#faq">FAQ</a>
489515
</div>
490516
<div class="nav-right">
491-
<a href="https://github.com/dirge-code/dirge" class="nav-gh">★ Star on GitHub</a>
517+
<a href="https://github.com/dirge-code/dirge" class="gh-star" aria-label="Star dirge-code/dirge on GitHub">
518+
<span class="gh-star-btn">
519+
<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Z"/></svg>
520+
Star
521+
</span>
522+
<span class="gh-star-count" id="ghStars"></span>
523+
</a>
492524
</div>
493525
</div>
494526
</nav>
@@ -1310,6 +1342,19 @@ <h5>Built with</h5>
13101342
d.style.display=(d.dataset.thc===th)?'':'none';
13111343
});
13121344
};
1345+
1346+
// Live GitHub star count for the nav star button. Graceful: if the API
1347+
// is unreachable or rate-limited, the count box stays hidden and the
1348+
// button still reads "★ Star".
1349+
fetch('https://api.github.com/repos/dirge-code/dirge')
1350+
.then(function(r){return r.ok?r.json():null;})
1351+
.then(function(d){
1352+
if(!d||typeof d.stargazers_count!=='number')return;
1353+
var n=d.stargazers_count, el=document.getElementById('ghStars');
1354+
el.textContent=n>=1000?(n/1000).toFixed(1).replace(/\.0$/,'')+'k':String(n);
1355+
el.style.display='inline-flex';
1356+
})
1357+
.catch(function(){});
13131358
</script>
13141359
</body>
13151360
</html>

0 commit comments

Comments
 (0)