diff --git a/packages/pixel-profile/src/cards/stats.ts b/packages/pixel-profile/src/cards/stats.ts index 4a16bbc..c394ae1 100644 --- a/packages/pixel-profile/src/cards/stats.ts +++ b/packages/pixel-profile/src/cards/stats.ts @@ -13,6 +13,7 @@ import { getThemeOptions } from '../theme' import { getBase64FromPixels, getPixelsFromPngBuffer, getPngBufferFromPixels, kFormatter, Rank } from '../utils' import { getPngBufferFromURL } from '../utils/converter' import { filterNotEmpty } from '../utils/filter' +import { getTopLanguages } from '../utils/top-languages' // import top-languages import { fontBuffer } from './PressStart2P-Regular' import { Resvg } from '@resvg/resvg-js' import satori from 'satori' @@ -20,6 +21,7 @@ import satori from 'satori' export type Stats = { name: string username: string + topLanguages: string // add top languages stat totalStars: number totalCommits: number totalIssues: number @@ -60,6 +62,9 @@ export async function renderStats(stats: Stats, options: Options = {}): Promise< dithering = false } = options + const token = process.env.PAT_1 || '' // add token for topLanguages + const topLanguages = await getTopLanguages(username, token) // add const topLanguages + const applyAvatarBorder = avatarBorder !== undefined ? avatarBorder : theme !== '' if (hiddenStatsKeys.includes('avatar')) { @@ -76,6 +81,7 @@ export async function renderStats(stats: Stats, options: Options = {}): Promise< const _stats = { name, avatar, + topLanguages, // add top languages to _stats stars: kFormatter(totalStars), commits: kFormatter(totalCommits), issues: kFormatter(totalIssues), diff --git a/packages/pixel-profile/src/templates/github-stats.tsx b/packages/pixel-profile/src/templates/github-stats.tsx index bac4043..50f1ea5 100644 --- a/packages/pixel-profile/src/templates/github-stats.tsx +++ b/packages/pixel-profile/src/templates/github-stats.tsx @@ -10,6 +10,7 @@ export type Stats = { prs: string rank: Rank['level'] stars: string + topLanguages: string // add top languages stat } export type TemplateOptions = { @@ -43,7 +44,7 @@ export const AVATAR_SIZE = { AVATAR_HEIGHT: 280 } -const mainStatsItems = ['stars', 'commits', 'issues', 'prs', 'contributions'] +const mainStatsItems = ['stars', 'commits', 'issues', 'prs', 'contributions', 'topLanguages'] // add top languages const getVisibleMainStatsCount = (hiddenStatsKeys: string[]) => mainStatsItems.filter((stat) => !hiddenStatsKeys.includes(stat)).length @@ -110,6 +111,22 @@ export function makeGithubStats(stats: Stats, options: TemplateOptions) { paddingRight: avatar ? 40 : 0 }} > + {isVisible('topLanguages') && ( +