Skip to content

Commit 47ffe84

Browse files
Fetch our own stars! (#28)
1 parent 6eb36db commit 47ffe84

File tree

5 files changed

+6223
-19
lines changed

5 files changed

+6223
-19
lines changed

Diff for: website/core/Footer.js

+5-14
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66
*/
77

88
const React = require('react')
9+
const GitHubStarButton = require('./GitHubStarButton')
910

1011
class Footer extends React.Component {
11-
docUrl (doc, language) {
12+
docUrl(doc, language) {
1213
const baseUrl = this.props.config.baseUrl
1314
return baseUrl + 'docs/' + (language ? language + '/' : '') + doc
1415
}
1516

16-
pageUrl (doc, language) {
17+
pageUrl(doc, language) {
1718
const baseUrl = this.props.config.baseUrl
1819
return baseUrl + (language ? language + '/' : '') + doc
1920
}
2021

21-
render () {
22+
render() {
2223
const currentYear = new Date().getFullYear()
2324
return (
2425
<footer className='nav-footer' id='footer'>
@@ -47,17 +48,7 @@ class Footer extends React.Component {
4748
User Showcase
4849
</a>
4950
<a href='https://gitter.im/isomorphic-git/Lobby'>Project Chat</a>
50-
<a
51-
className='github-button'
52-
href={this.props.config.repoUrl}
53-
data-icon='octicon-star'
54-
data-count-href='/isomorphic-git/isomorphic-git/stargazers'
55-
data-show-count
56-
data-count-aria-label='# stargazers on GitHub'
57-
aria-label='Star this project on GitHub'
58-
>
59-
Github
60-
</a>
51+
<GitHubStarButton />
6152
</div>
6253
<div>
6354
<h5>More</h5>

Diff for: website/core/GitHubStarButton.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const React = require('react')
2+
3+
const script = `
4+
void async function() {
5+
const response = await fetch('https://api.github.com/repos/isomorphic-git/isomorphic-git', {
6+
headers: { accept: 'application/vnd.github.v3+json' }
7+
})
8+
const data = await response.json()
9+
document.querySelector('#gitHubStars').textContent = '(' + data.stargazers_count + '⭐)'
10+
}()
11+
`
12+
13+
class GitHubStarButton extends React.Component {
14+
render() {
15+
// "Server-side" rendered, so `componentDidMount` wouldn't be called
16+
return (
17+
<div>
18+
<a href="https://github.com/isomorphic-git/isomorphic-git">GitHub <span id="gitHubStars" /></a>
19+
<script dangerouslySetInnerHTML={{ __html: script }} />
20+
</div>
21+
);
22+
}
23+
}
24+
25+
module.exports = GitHubStarButton

Diff for: website/i18n/en.json

-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@
1313
"checkout": "checkout",
1414
"clone": "clone",
1515
"commit": "commit",
16-
"compare": "How does it compare with X?",
17-
"Compare with X": "Compare with X",
1816
"config": "config",
1917
"currentBranch": "currentBranch",
2018
"dir-vs-gitdir": "`dir` vs `gitdir`",
2119
"dir vs gitdir": "dir vs gitdir",
22-
"faq": "Frequently Asked Questions",
23-
"FAQ": "FAQ",
2420
"fetch": "fetch",
2521
"findRoot": "findRoot",
2622
"getRemoteInfo": "getRemoteInfo",

0 commit comments

Comments
 (0)