From b3d3543269ffe5a3388b340ea75872c5314a935d Mon Sep 17 00:00:00 2001 From: Ayo Date: Thu, 13 Oct 2022 17:15:00 +0200 Subject: [PATCH] feat: add alt texts for accessibility --- src/GithubStats.astro | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/GithubStats.astro b/src/GithubStats.astro index 2fb7292..2a9858f 100644 --- a/src/GithubStats.astro +++ b/src/GithubStats.astro @@ -4,18 +4,25 @@ export interface Props { topLanguages?: boolean; repo?: string; showIcons?: boolean; + altText?: string; } -const { username, repo, topLanguages, showIcons } = Astro.props; +const { username, repo, topLanguages, showIcons, altText } = Astro.props; const baseUrl = 'https://github-readme-stats.vercel.app/api/'; let url = `${baseUrl}?username=${username}&show_icons=${!!showIcons}`; +let alt = `GitHub stats for account: ${username}`; + if (repo) { url = `${baseUrl}/pin/?username=${username}&repo=${repo}`; + alt = `GitHub stats for repository: ${username}/${repo}`; } if (topLanguages) { url = `${baseUrl}top-langs?username=${username}`; + alt = `GitHub top languages for account: ${username}`; } + +alt = altText || alt; --- - +{alt}