feat: add alt texts for accessibility
This commit is contained in:
parent
9229ca5f15
commit
b3d3543269
1 changed files with 9 additions and 2 deletions
|
@ -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} />
|
||||
|
|
Loading…
Reference in a new issue