diff --git a/src/fetchRepo.js b/src/fetchRepo.js index 8f7c83d..0c730ea 100644 --- a/src/fetchRepo.js +++ b/src/fetchRepo.js @@ -9,6 +9,7 @@ const fetcher = (variables, token) => { name nameWithOwner isPrivate + isArchived stargazers { totalCount } diff --git a/src/renderRepoCard.js b/src/renderRepoCard.js index 383d357..56fb7cd 100644 --- a/src/renderRepoCard.js +++ b/src/renderRepoCard.js @@ -8,6 +8,7 @@ const renderRepoCard = (repo, options = {}) => { description, primaryLanguage, stargazers, + isArchived, forkCount, } = repo; const { title_color, icon_color, text_color, bg_color, show_owner } = options; @@ -31,19 +32,33 @@ const renderRepoCard = (repo, options = {}) => { const totalStars = kFormatter(stargazers.totalCount); const totalForks = kFormatter(forkCount); + + const archiveBadge = isArchived + ? ` + + + Archived + + ` + : ""; + return ` - + ${icons.contribs} + ${archiveBadge} + ${header} ${encodeHTML(desc)} diff --git a/tests/renderRepoCard.test.js b/tests/renderRepoCard.test.js index 5fa84ef..27ca23b 100644 --- a/tests/renderRepoCard.test.js +++ b/tests/renderRepoCard.test.js @@ -147,4 +147,15 @@ describe("Test renderRepoCard", () => { "#252525" ); }); + + it("should render archive badge if repo is archived", () => { + document.body.innerHTML = renderRepoCard({ + ...data_repo.repository, + isArchived: true, + }); + + expect(queryByTestId(document.body, "archive-badge")).toHaveTextContent( + "Archived" + ); + }); });