feat: add alt texts for accessibility

This commit is contained in:
Ayo 2022-10-13 17:15:00 +02:00
parent 9229ca5f15
commit b3d3543269

View file

@ -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;
---
<img src={url} />
<img src={url} alt={alt} />