Skip to content

Commit

Permalink
fix #37
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 20, 2019
1 parent c164f6e commit aa8b22d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
31 changes: 21 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"babel-polyfill": "^6.26.0",
"cheerio": "^1.0.0-rc.2",
"cheerio": "^1.0.0-rc.3",
"classnames": "^2.2.5",
"linux-command": "^1.2.8",
"prop-types": "^15.6.0",
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Github.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ export default class Github extends Component {
const href = $(item).find('h1 a').attr('href').replace(/(\n|\s)/g, '');
const language = $(item).find('span[itemprop=programmingLanguage]').text().replace(/(\n|\s)/g, '');
const languageColor = $(item).find('span.repo-language-color');
const stargazersCount = $(item).find('svg[aria-label="star"].octicon.octicon-star').parent().text().replace(/(\n|\s|,)/g, '');
const forked = $(item).find('svg[aria-label="fork"].octicon.octicon-repo-forked').parent().text().replace(/(\n|\s|,)/g, '');
const todayStar = $(item).find('.float-sm-right svg.octicon.octicon-star').parent().text().replace(/(\n|,)/g, '').trim();
const stargazersCount = $(item).find('span[aria-label="star"] svg[aria-label="star"].octicon.octicon-star').parent().parent().text().replace(/(\n|\s|,)/g, '');
const forked = $(item).find('span[aria-label="fork"] svg.octicon.octicon-repo-forked').parent().parent().text().replace(/(\n|\s|,)/g, '');
const todayStar = $(item).find('span.float-sm-right').text().replace(/(\n|,)/g, '').trim();
const description = $(item).find('p.text-gray').text().replace(/(\n)/g, '').trim();
/* eslint-enable */
let color = '';
if (language && languageColor && languageColor.css) {
color = languageColor.css('background-color');
}
resultData.push({ full_name: fullName, language, color, description, forked, stargazers_count: Number(stargazersCount), todayStar, html_url: href, rank: idx + 1 });
resultData.push({ full_name: fullName, language, color, description, forked, stargazers_count: parseInt(stargazersCount, 10), todayStar, html_url: href, rank: idx + 1 });
});
if (!resultData) return;
localStorage.setItem('github-list', JSON.stringify(resultData));
Expand Down

0 comments on commit aa8b22d

Please sign in to comment.