const {
kFormatter,
encodeHTML,
getCardColors,
FlexLayout,
} = require("../src/utils");
const icons = require("./icons");
const toEmoji = require("emoji-name-map");
const renderRepoCard = (repo, options = {}) => {
const {
name,
nameWithOwner,
description,
primaryLanguage,
stargazers,
isArchived,
isTemplate,
forkCount,
} = repo;
const {
title_color,
icon_color,
text_color,
bg_color,
show_owner,
theme = "default_repocard",
} = options;
const header = show_owner ? nameWithOwner : name;
const langName = (primaryLanguage && primaryLanguage.name) || "Unspecified";
const langColor = (primaryLanguage && primaryLanguage.color) || "#333";
const height = 120;
const shiftText = langName.length > 15 ? 0 : 30;
let desc = description || "No description provided";
// parse emojis to unicode
desc = desc.replace(/:\w+:/gm, (emoji) => {
return toEmoji.get(emoji) || "";
});
if (desc.length > 55) {
desc = `${desc.slice(0, 55)}..`;
}
// returns theme based colors with proper overrides and defaults
const { titleColor, textColor, iconColor, bgColor } = getCardColors({
title_color,
icon_color,
text_color,
bg_color,
theme,
});
const totalStars = kFormatter(stargazers.totalCount);
const totalForks = kFormatter(forkCount);
const getBadgeSVG = (label) => `
${label}
`;
const svgLanguage = primaryLanguage
? `
${langName}
`
: "";
const svgStars =
stargazers.totalCount > 0 &&
`
${totalStars}
`;
const svgForks =
forkCount > 0 &&
`
${totalForks}
`;
return `
`;
};
module.exports = renderRepoCard;