Fix GitHub badge (#12161)

* Extract component

* Remove rounded border form GitHub Stars badge

* Add `alt` text
This commit is contained in:
Marcus Blättermann 2023-01-24 13:53:28 +01:00 committed by GitHub
parent 3aa61e615f
commit 7160f7835d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -195,6 +195,19 @@ const SpaCyVersion = ({ version }) => {
)) ))
} }
const ImageGitHub = ({ url, isRounded, title }) => (
// eslint-disable-next-line @next/next/no-img-element
<img
style={{
borderRadius: isRounded ? '1em' : 0,
marginRight: '0.5rem',
verticalAlign: 'middle',
}}
src={`https://img.shields.io/github/${url}`}
alt={`${title} on GitHub`}
/>
)
const Project = ({ data, components }) => ( const Project = ({ data, components }) => (
<> <>
<Title title={data.title || data.id} teaser={data.slogan} image={data.thumb}> <Title title={data.title || data.id} teaser={data.slogan} image={data.thumb}>
@ -203,23 +216,20 @@ const Project = ({ data, components }) => (
{data.spacy_version && <SpaCyVersion version={data.spacy_version} />} {data.spacy_version && <SpaCyVersion version={data.spacy_version} />}
{data.github && ( {data.github && (
<Link to={`https://github.com/${data.github}`} hidden> <Link to={`https://github.com/${data.github}`} hidden>
{[ <ImageGitHub
`release/${data.github}/all.svg?style=flat-square`, title={data.title || data.id}
`license/${data.github}.svg?style=flat-square`, url={`release/${data.github}/all.svg?style=flat-square`}
`stars/${data.github}.svg?style=social&label=Stars`, isRounded
].map((url, i) => ( />
// eslint-disable-next-line @next/next/no-img-element <ImageGitHub
<img title={data.title || data.id}
style={{ url={`license/${data.github}.svg?style=flat-square`}
borderRadius: '1em', isRounded
marginRight: '0.5rem', />
verticalAlign: 'middle', <ImageGitHub
}} title={data.title || data.id}
key={i} url={`stars/${data.github}.svg?style=social&label=Stars`}
src={`https://img.shields.io/github/${url}`} />
alt=""
/>
))}
</Link> </Link>
)} )}
</p> </p>