Skip to content

Commit ea47f3e

Browse files
committed
Add github stars
1 parent 52c823c commit ea47f3e

3 files changed

Lines changed: 60 additions & 1 deletion

File tree

index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@
8383
<svg width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h0"/></svg>
8484
<a href="https://steamcommunity.com/workshop/filedetails/?id=3124567099">Inferno Night</a> by Angel, created by decompiling with Source 2 Viewer.
8585
</div>
86+
<a href="https://github.com/ValveResourceFormat/ValveResourceFormat" class="github-stars" id="js-stars">
87+
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16">
88+
<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"></path>
89+
</svg>
90+
<span>
91+
<b id="js-stars-count"></b>
92+
stars
93+
</span>
94+
</a>
8695
</div>
8796
</div>
8897

static/main.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
fetch( 'https://api.github.com/repositories/42366054' )
2+
.then( function( response )
3+
{
4+
if( !response.ok )
5+
{
6+
throw new Error( 'Failed to fetch github repo info' );
7+
}
8+
9+
return response.json();
10+
} )
11+
.then( function( response )
12+
{
13+
const starsCount = document.getElementById( 'js-stars-count' );
14+
const formatter = new Intl.NumberFormat( 'en', { notation: 'compact' } );
15+
starsCount.textContent = formatter.format( response.stargazers_count );
16+
} );
17+
118
fetch( 'https://api.github.com/repositories/42366054/releases/latest' )
219
.then( function( response )
320
{

static/style.css

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ a:active {
154154

155155
.hero-right {
156156
display: flex;
157-
flex-direction: column;
157+
flex-direction: column;
158158
align-self: center;
159159
gap: 2px;
160160
flex-basis: 1000px;
@@ -532,3 +532,36 @@ a.hljs-built_in {
532532
grid-template-columns: 1fr;
533533
}
534534
}
535+
536+
.github-stars {
537+
display: inline-flex;
538+
align-items: center;
539+
align-self: center;
540+
gap: 0.5rem;
541+
padding: 0.5rem 0.75rem;
542+
font-size: 1rem;
543+
line-height: 1;
544+
text-decoration: none;
545+
color: #fff;
546+
background: rgb(255 255 255 / 10%);
547+
border: 1px solid rgb(255 255 255 / 20%);
548+
border-radius: .5rem;
549+
margin-top: 1rem;
550+
551+
&:hover {
552+
background: rgb(255 255 255 / 15%);
553+
color: #fff;
554+
text-decoration: underline;
555+
}
556+
557+
svg {
558+
fill: currentColor;
559+
flex-shrink: 0;
560+
}
561+
562+
@media (min-width: 841px) {
563+
position: absolute;
564+
top: 0;
565+
right: 1rem;
566+
}
567+
}

0 commit comments

Comments
 (0)