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 }) => (
<>
<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.github && (
<Link to={`https://github.com/${data.github}`} hidden>
{[
`release/${data.github}/all.svg?style=flat-square`,
`license/${data.github}.svg?style=flat-square`,
`stars/${data.github}.svg?style=social&label=Stars`,
].map((url, i) => (
// eslint-disable-next-line @next/next/no-img-element
<img
style={{
borderRadius: '1em',
marginRight: '0.5rem',
verticalAlign: 'middle',
}}
key={i}
src={`https://img.shields.io/github/${url}`}
alt=""
/>
))}
<ImageGitHub
title={data.title || data.id}
url={`release/${data.github}/all.svg?style=flat-square`}
isRounded
/>
<ImageGitHub
title={data.title || data.id}
url={`license/${data.github}.svg?style=flat-square`}
isRounded
/>
<ImageGitHub
title={data.title || data.id}
url={`stars/${data.github}.svg?style=social&label=Stars`}
/>
</Link>
)}
</p>