feat: display username in repo card (optional) (#78)

* Display username in repo card (optional)

* fix: show_owner boolean flag & used nameWithOwner from gql api
This commit is contained in:
omrilotan
2020-07-16 15:33:33 +03:00
committed by GitHub
parent 597dac2985
commit 9e4d83247e
6 changed files with 37 additions and 8 deletions

View File

@ -7,6 +7,7 @@ const fetcher = (variables, token) => {
query: `
fragment RepoInfo on Repository {
name
nameWithOwner
stargazers {
totalCount
}

View File

@ -2,9 +2,17 @@ const { kFormatter, encodeHTML, fallbackColor } = require("../src/utils");
const icons = require("./icons");
const renderRepoCard = (repo, options = {}) => {
const { name, description, primaryLanguage, stargazers, forkCount } = repo;
const { title_color, icon_color, text_color, bg_color } = options;
const {
name,
nameWithOwner,
description,
primaryLanguage,
stargazers,
forkCount,
} = repo;
const { title_color, icon_color, text_color, bg_color, show_owner } = options;
const header = show_owner ? nameWithOwner : name;
const langName = primaryLanguage ? primaryLanguage.name : "Unspecified";
const langColor = primaryLanguage ? primaryLanguage.color : "#333";
@ -36,7 +44,7 @@ const renderRepoCard = (repo, options = {}) => {
${icons.contribs}
</svg>
<text x="50" y="38" class="header">${name}</text>
<text x="50" y="38" class="header">${header}</text>
<text class="description" x="25" y="70">${encodeHTML(desc)}</text>
<g transform="translate(30, 100)">