Skip to content

Commit 0554d08

Browse files
committed
adding stars and forks count
Signed-off-by: Vanessa Sochat <[email protected]>
1 parent f28ea89 commit 0554d08

File tree

2 files changed

+115
-1
lines changed

2 files changed

+115
-1
lines changed

_includes/header.html

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,34 @@
1515
</div>
1616
<div class="navbar-nav d-none d-lg-block">
1717
<input type="search" class="form-control td-search-input" placeholder="&#xf002 Search this site…" aria-label="Search this site…" autocomplete="off">
18-
</div>
18+
</div>
19+
20+
<div class="navbar-nav d-none d-lg-block">
21+
<a class="gh-source" data-gh-source="github" href="{{ site.repo }}" title="Go to repository" data-md-state="done">
22+
<div class="gh-source__repository">
23+
<i class="fab fa fa-github fa-2x" style='padding-right:20px; float:left; margin-top:5px'></i>
24+
{{ site.github_user }}/{{ site.github_repo }}
25+
<ul class="gh-source__facts"><li class="gh-source__fact" id='stars'></li><li id="forks" class="gh-source__fact"></li></ul></div></a>
26+
</div>
27+
</div>
28+
29+
1930
</nav>
2031
</header>
2132

33+
<script>
34+
$(document).ready(function() {
35+
var url = "https://api.github.com/search/repositories?q={{ site.github_user }}/{{ site.github_repo }}";
36+
fetch(url, {
37+
headers: {"Accept":"application/vnd.github.preview"}
38+
}).then(function(e) {
39+
return e.json()
40+
}).then(function(r) {
41+
console.log(r.items[0])
42+
stars = r.items[0]['stargazers_count']
43+
forks = r.items[0]['forks_count']
44+
$('#stars').text(stars + " Stars")
45+
$('#forks').text(forks + " Forks")
46+
});
47+
});
48+
</script>

assets/css/main.css

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,93 @@ excluded_in_search: true
66
@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,700,700i";
77
@fa-font-path: "../webfonts";
88

9+
.gh-source {
10+
display: block;
11+
padding-right: 1.2rem;
12+
transition: opacity .25s;
13+
font-size: 0.8rem;
14+
line-height: 1.2;
15+
color: white;
16+
white-space: nowrap;
17+
}
18+
[dir=rtl] .gh-source {
19+
padding-right: 0;
20+
padding-left: 1.2rem;
21+
}
22+
.gh-source:hover {
23+
opacity: .7;
24+
}
25+
.gh-source__icon+.gh-source__repository {
26+
margin-left: -4.4rem;
27+
padding-left: 4rem;
28+
}
29+
[dir=rtl] .gh-source__icon+.gh-source__repository {
30+
margin-right: -4.4rem;
31+
margin-left: 0;
32+
padding-right: 4rem;
33+
padding-left: 0;
34+
}
35+
.gh-source__repository {
36+
display: inline-block;
37+
max-width: 100%;
38+
margin-left: 1.2rem;
39+
font-weight: 700;
40+
text-overflow: ellipsis;
41+
overflow: hidden;
42+
vertical-align: middle;
43+
}
44+
.gh-source__facts {
45+
margin: 0;
46+
padding: 0;
47+
font-size: 0.8rem;
48+
font-weight: 700;
49+
list-style-type: none;
50+
opacity: .75;
51+
overflow: hidden;
52+
}
53+
[data-md-state=done] .gh-source__facts {
54+
-webkit-animation: md-source__facts--done .25s ease-in;
55+
animation: md-source__facts--done .25s ease-in;
56+
}
57+
.gh-source__fact {
58+
float: left;
59+
}
60+
[dir=rtl] .gh-source__fact {
61+
float: right;
62+
}
63+
[data-md-state=done] .gh-source__fact {
64+
-webkit-animation: md-source__fact--done .4s ease-out;
65+
animation: md-source__fact--done .4s ease-out;
66+
}
67+
.gh-source__fact:before {
68+
margin: 0 .2rem;
69+
content: "\B7"}
70+
.gh-source__fact:first-child:before {
71+
display: none;
72+
}
73+
.gh-source-file {
74+
display: inline-block;
75+
margin: 1em .5em 1em 0;
76+
padding-right: .5rem;
77+
border-radius: .2rem;
78+
background-color: rgba(0, 0, 0, .07);
79+
font-size: 1.28rem;
80+
list-style-type: none;
81+
cursor: pointer;
82+
overflow: hidden;
83+
}
84+
.gh-source-file:before {
85+
display: inline-block;
86+
margin-right: .5rem;
87+
padding: .5rem;
88+
background-color: rgba(0, 0, 0, .26);
89+
color: #fff;
90+
font-size: 1.6rem;
91+
content: "\E86F";
92+
vertical-align: middle;
93+
}
94+
95+
996
/*!* Bootstrap v4.1.3 (https://getbootstrap.com/)
1097
* Copyright 2011-2018 The Bootstrap Authors
1198
* Copyright 2011-2018 Twitter, Inc.

0 commit comments

Comments
 (0)